home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / cc / g++-dist / stmt.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-02-25  |  149.1 KB  |  4,901 lines

  1. /* Expands front end tree to back end RTL for GNU C-Compiler
  2.    Copyright (C) 1987, 1988, 1989 Free Software Foundation, Inc.
  3.  
  4. This file is part of GNU CC.
  5.  
  6. GNU CC is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 1, or (at your option)
  9. any later version.
  10.  
  11. GNU CC is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with GNU CC; see the file COPYING.  If not, write to
  18. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  19.  
  20.  
  21. /* This file handles the generation of rtl code from tree structure
  22.    above the level of expressions, using subroutines in exp*.c and emit-rtl.c.
  23.    It also creates the rtl expressions for parameters and auto variables
  24.    and has full responsibility for allocating stack slots.
  25.  
  26.    The functions whose names start with `expand_' are called by the
  27.    parser to generate RTL instructions for various kinds of constructs.
  28.  
  29.    Some control and binding constructs require calling several such
  30.    functions at different times.  For example, a simple if-then
  31.    is expanded by calling `expand_start_cond' (with the condition-expression
  32.    as argument) before parsing the then-clause and calling `expand_end_cond'
  33.    after parsing the then-clause.
  34.  
  35.    `expand_function_start' is called at the beginning of a function,
  36.    before the function body is parsed, and `expand_function_end' is
  37.    called after parsing the body.
  38.  
  39.    Call `assign_stack_local' to allocate a stack slot for a local variable.
  40.    This is usually done during the RTL generation for the function body,
  41.    but it can also be done in the reload pass when a pseudo-register does
  42.    not get a hard register.
  43.  
  44.    Call `put_var_into_stack' when you learn, belatedly, that a variable
  45.    previously given a pseudo-register must in fact go in the stack.
  46.    This function changes the DECL_RTL to be a stack slot instead of a reg
  47.    then scans all the RTL instructions so far generated to correct them.  */
  48.  
  49. #include "config.h"
  50.  
  51. #include <stdio.h>
  52.  
  53. #include "rtl.h"
  54. #include "tree.h"
  55. #include "flags.h"
  56. #include "insn-flags.h"
  57. #include "insn-config.h"
  58. #include "insn-codes.h"
  59. #include "expr.h"
  60. #include "regs.h"
  61. #include "hard-reg-set.h"
  62. #include "recog.h"
  63. #include "obstack.h"
  64.  
  65. #define obstack_chunk_alloc xmalloc
  66. #define obstack_chunk_free free
  67. struct obstack stmt_obstack;
  68.  
  69. extern int xmalloc ();
  70. extern void free ();
  71.  
  72. #define MAX(x,y) (((x) > (y)) ? (x) : (y))
  73. #define MIN(x,y) (((x) < (y)) ? (x) : (y))
  74.  
  75. /* Nonzero if function being compiled pops its args on return.
  76.    May affect compilation of return insn or of function epilogue.  */
  77.  
  78. int current_function_pops_args;
  79.  
  80. /* Nonzero if function being compiled needs to be given an address
  81.    where the value should be stored.  */
  82.  
  83. int current_function_returns_struct;
  84.  
  85. /* Nonzero if function being compiled needs to
  86.    return the address of where it has put a structure value.  */
  87.  
  88. int current_function_returns_pcc_struct;
  89.  
  90. /* Nonzero if function being compiled needs to be passed a static chain.  */
  91.  
  92. int current_function_needs_context;
  93.  
  94. /* Nonzero if function being compiled can call setjmp.  */
  95.  
  96. int current_function_calls_setjmp;
  97.  
  98. /* Nonzero if function being compiled can call alloca,
  99.    either as a subroutine or builtin.  */
  100.  
  101. int current_function_calls_alloca;
  102.  
  103. /* Nonzero if the current function returns a pointer type */
  104.  
  105. int current_function_returns_pointer;
  106.  
  107. /* If function's args have a fixed size, this is that size, in bytes.
  108.    Otherwise, it is -1.
  109.    May affect compilation of return insn or of function epilogue.  */
  110.  
  111. int current_function_args_size;
  112.  
  113. /* # bytes the prologue should push and pretend that the caller pushed them.
  114.    The prologue must do this, but only if parms can be passed in registers.  */
  115.  
  116. int current_function_pretend_args_size;
  117.  
  118. /* Name of function now being compiled.  */
  119.  
  120. char *current_function_name;
  121.  
  122. /* Label that will go on parm cleanup code, if any.
  123.    Jumping to this label runs cleanup code for parameters, if
  124.    such code must be run.  Following this code is the logical return label.  */
  125.  
  126. rtx cleanup_label;
  127.  
  128. /* Label that will go on function epilogue.
  129.    Jumping to this label serves as a "return" instruction
  130.    on machines which require execution of the epilogue on all returns.  */
  131.  
  132. rtx return_label;
  133.  
  134. /* List (chain of EXPR_LISTs) of pseudo-regs of SAVE_EXPRs.
  135.    So we can mark them all live at the end of the function, if nonopt.  */
  136. rtx save_expr_regs;
  137.  
  138. /* List (chain of EXPR_LISTs) of all stack slots in this function.
  139.    Made for the sake of unshare_all_rtl.  */
  140. rtx stack_slot_list;
  141.  
  142. /* Filename and line number of last line-number note,
  143.    whether we actually emitted it or not.  */
  144. char *emit_filename;
  145. int emit_lineno;
  146.  
  147. /* Insn after which register parms and SAVE_EXPRs are born, if nonopt.  */
  148. static rtx parm_birth_insn;
  149.  
  150. /* The FUNCTION_DECL node for the function being compiled.  */
  151.  
  152. static tree this_function;
  153.  
  154. /* Offset to end of allocated area of stack frame.
  155.    If stack grows down, this is the address of the last stack slot allocated.
  156.    If stack grows up, this is the address for the next slot.  */
  157. static int frame_offset;
  158.  
  159. /* Nonzero if a stack slot has been generated whose address is not
  160.    actually valid.  It means that the generated rtl must all be scanned
  161.    to detect and correct the invalid addresses where they occur.  */
  162. static int invalid_stack_slot;
  163.  
  164. /* Label to jump back to for tail recursion, or 0 if we have
  165.    not yet needed one for this function.  */
  166. static rtx tail_recursion_label;
  167.  
  168. /* Place after which to insert the tail_recursion_label if we need one.  */
  169. static rtx tail_recursion_reentry;
  170.  
  171. /* Each time we expand an expression-statement,
  172.    record the expr's type and its RTL value here.  */
  173.  
  174. static tree last_expr_type;
  175. static rtx last_expr_value;
  176.  
  177. /* Chain of all RTL_EXPRs that have insns in them.  */
  178. static tree rtl_expr_chain;
  179.  
  180. /* Last insn of those whose job was to put parms into their nominal homes.  */
  181. static rtx last_parm_insn;
  182.  
  183. /* Cleanup lists are required for binding levels regardless of whether
  184.    that binding level has cleanups or not.  This node satisfies that
  185.    need for all binding levels.  */
  186. static tree empty_cleanup_list;
  187.  
  188. /* Functions and data structures for expanding case statements.  */
  189.  
  190. /* Case label structure, used to hold info on labels within case
  191.    statements.  We handle "range" labels; for a single-value label
  192.    as in C, the high and low limits are the same.  */
  193.  
  194. struct case_node
  195. {
  196.   struct case_node    *left;
  197.   struct case_node    *right;
  198.   struct case_node    *parent;
  199.   tree            low;
  200.   tree            high;
  201.   tree            test_label;
  202.   tree            code_label;
  203. };
  204.  
  205. typedef struct case_node case_node;
  206. typedef struct case_node *case_node_ptr;
  207.  
  208. extern void balance_case_nodes ();
  209. extern void emit_case_nodes ();
  210. extern void group_case_nodes ();
  211. extern void emit_jump_if_reachable ();
  212.  
  213. /* Stack of control and binding constructs we are currently inside.
  214.  
  215.    These constructs begin when you call `expand_start_WHATEVER'
  216.    and end when you call `expand_end_WHATEVER'.  This stack records
  217.    info about how the construct began that tells the end-function
  218.    what to do.  It also may provide information about the construct
  219.    to alter the behavior of other constructs within the body.
  220.    For example, they may affect the behavior of C `break' and `continue'.
  221.  
  222.    Each construct gets one `struct nesting' object.
  223.    All of these objects are chained through the `all' field.
  224.    `nesting_stack' points to the first object (innermost construct).
  225.    The position of an entry on `nesting_stack' is in its `depth' field.
  226.  
  227.    Each type of construct has its own individual stack.
  228.    For example, loops have `loop_stack'.  Each object points to the
  229.    next object of the same type through the `next' field.
  230.  
  231.    Some constructs are visible to `break' exit-statements and others
  232.    are not.  Which constructs are visible depends on the language.
  233.    Therefore, the data structure allows each construct to be visible
  234.    or not, according to the args given when the construct is started.
  235.    The construct is visible if the `exit_label' field is non-null.
  236.    In that case, the value should be a CODE_LABEL rtx.  */
  237.  
  238. struct nesting
  239. {
  240.   struct nesting *all;
  241.   struct nesting *next;
  242.   int depth;
  243.   rtx exit_label;
  244.   union
  245.     {
  246.       /* For conds (if-then and if-then-else statements).  */
  247.       struct
  248.     {
  249.       /* Label on the else-part, if any, else 0.  */
  250.       rtx else_label;
  251.       /* Label at the end of the whole construct.  */
  252.       rtx after_label;
  253.     } cond;
  254.       /* For loops.  */
  255.       struct
  256.     {
  257.       /* Label at the top of the loop; place to loop back to.  */
  258.       rtx start_label;
  259.       /* Label at the end of the whole construct.  */
  260.       rtx end_label;
  261.       /* Label for `continue' statement to jump to;
  262.          this is in front of the stepper of the loop.  */
  263.       rtx continue_label;
  264.     } loop;
  265.       /* For variable binding contours.  */
  266.       struct
  267.     {
  268.       /* Nonzero => value to restore stack to on exit.  */
  269.       rtx stack_level;
  270.       /* The NOTE that starts this contour.
  271.          Used by expand_goto to check whether the destination
  272.          is within each contour or not.  */
  273.       rtx first_insn;
  274.       /* Innermost containing binding contour that has a stack level.  */
  275.       struct nesting *innermost_stack_block;
  276.       /* List of cleanups to be run on exit from this contour.
  277.          This is a list of expressions to be evaluated.
  278.          The TREE_PURPOSE of each link is the ..._DECL node
  279.          which the cleanup pertains to.  */
  280.       tree cleanups;
  281.       /* List of cleanup-lists of blocks containing this block,
  282.          as they were at the locus where this block appears.
  283.          There is an element for each containing block,
  284.          ordered innermost containing block first, once there are
  285.          any cleanups at all.
  286.          The element's TREE_VALUE is the cleanup-list of that block,
  287.          which may be null.  */
  288.       tree outer_cleanups;
  289.       /* Chain of labels defined inside this binding contour.
  290.          For contours that have stack levels or cleanups.  */
  291.       struct label_chain *label_chain;
  292.     } block;
  293.       /* For switch (C) or case (Pascal) statements,
  294.      and also for dummies (see `expand_start_case_dummy').  */
  295.       struct
  296.     {
  297.       /* The insn after which the case dispatch should finally
  298.          be emitted.  Zero for a dummy.  */
  299.       rtx start;
  300.       /* A list of case labels, kept in ascending order by value
  301.          as the list is built.
  302.          During expand_end_case, this list may be rearranged into a
  303.          nearly balanced binary tree.  */
  304.       struct case_node *case_list;
  305.       /* Label to jump to if no case matches.  */
  306.       tree default_label;
  307.       /* The expression to be dispatched on.  */
  308.       tree index_expr;
  309.       /* Type that INDEX_EXPR should be converted to.  */
  310.       tree nominal_type;
  311.       /* Number of range exprs in case statement.  */
  312.       short num_ranges;
  313.     } case_stmt;
  314.       /* For exception contours.  */
  315.       struct
  316.     {
  317.       /* List of exceptions raised.  This is a TREE_LIST
  318.          of whatever you want.  */
  319.       tree raised;
  320.       /* List of exceptions caught.  This is also a TREE_LIST
  321.          of whatever you want.  As a special case, it has the
  322.          value `void_type_node' if it handles default exceptions.  */
  323.       tree handled;
  324.  
  325.       /* First insn of TRY block, in case resumptive model is needed.  */
  326.       rtx first_insn;
  327.       /* Label for the catch clauses.  */
  328.       rtx except_label;
  329.       /* Label for unhandled exceptions.  */
  330.       rtx unhandled_label;
  331.       /* Label at the end of whole construct.  */
  332.       rtx after_label;
  333.       /* Label which "escapes" the exception construct.
  334.          Like EXIT_LABEL for BREAK construct, but for exceptions.  */
  335.       rtx escape_label;
  336.     } except_stmt;
  337.     } data;
  338. };
  339.  
  340. /* Chain of all pending binding contours.  */
  341. struct nesting *block_stack;
  342.  
  343. /* Chain of all pending binding contours that restore stack levels
  344.    or have cleanups.  */
  345. struct nesting *stack_block_stack;
  346.  
  347. /* Chain of all pending conditional statements.  */
  348. struct nesting *cond_stack;
  349.  
  350. /* Chain of all pending loops.  */
  351. struct nesting *loop_stack;
  352.  
  353. /* Chain of all pending case or switch statements.  */
  354. struct nesting *case_stack;
  355.  
  356. /* Chain of all pending exception contours.  */
  357. struct nesting *except_stack;
  358.  
  359. /* Separate chain including all of the above,
  360.    chained through the `all' field.  */
  361. struct nesting *nesting_stack;
  362.  
  363. /* Number of entries on nesting_stack now.  */
  364. int nesting_depth;
  365.  
  366. /* Pop one of the sub-stacks, such as `loop_stack' or `cond_stack';
  367.    and pop off `nesting_stack' down to the same level.  */
  368.  
  369. #define POPSTACK(STACK)                    \
  370. do { int initial_depth = nesting_stack->depth;        \
  371.      do { struct nesting *this = STACK;            \
  372.       STACK = this->next;                \
  373.       nesting_stack = this->all;            \
  374.       nesting_depth = this->depth;            \
  375.       obstack_free (&stmt_obstack, this); }        \
  376.      while (nesting_depth > initial_depth); } while (0)
  377.  
  378. static int warn_if_unused_value ();
  379. static void expand_goto_internal ();
  380. static int expand_fixup ();
  381. static void fixup_gotos ();
  382. static void expand_cleanups ();
  383. static void fixup_cleanups ();
  384. static void expand_null_return_1 ();
  385. static int tail_recursion_args ();
  386. static void fixup_stack_slots ();
  387. static rtx fixup_stack_1 ();
  388. static rtx fixup_memory_subreg ();
  389. static rtx walk_fixup_memory_subreg ();
  390. static void fixup_var_refs ();
  391. static void fixup_var_refs_insns ();
  392. static rtx fixup_var_refs_1 ();
  393. static rtx parm_stack_loc ();
  394. static void optimize_bit_field ();
  395. static void do_jump_if_equal ();
  396.  
  397. /* Emit a no-op instruction.  */
  398.  
  399. rtx
  400. emit_nop ()
  401. {
  402.   rtx last_insn = get_last_insn ();
  403.   if (!optimize
  404.       && (GET_CODE (last_insn) == CODE_LABEL
  405.       || prev_real_insn (last_insn) == 0))
  406.     emit_insn (gen_nop ());
  407. }
  408.  
  409. /* Return the rtx-label that corresponds to a LABEL_DECL,
  410.    creating it if necessary.  */
  411.  
  412. rtx /* @@ non-static for case.c.  */
  413. label_rtx (label)
  414.      tree label;
  415. {
  416.   if (TREE_CODE (label) != LABEL_DECL)
  417.     abort ();
  418.  
  419.   if (DECL_RTL (label))
  420.     return DECL_RTL (label);
  421.  
  422.   return DECL_RTL (label) = gen_label_rtx ();
  423. }
  424.  
  425. /* Add an unconditional jump to LABEL as the next sequential instruction.  */
  426.  
  427. void
  428. emit_jump (label)
  429.      rtx label;
  430. {
  431.   do_pending_stack_adjust ();
  432.   emit_jump_insn (gen_jump (label));
  433.   emit_barrier ();
  434. }
  435.  
  436. /* Handle goto statements and the labels that they can go to.  */
  437.  
  438. /* In some cases it is impossible to generate code for a forward goto 
  439.    until the label definition is seen.  This happens when it may be necessary
  440.    for the goto to reset the stack pointer: we don't yet know how to do that.
  441.    So expand_goto puts an entry on this fixup list.
  442.    Each time a binding contour that resets the stack is exited,
  443.    we check each fixup.
  444.    If the target label has now been defined, we can insert the proper code.  */
  445.  
  446. struct goto_fixup
  447. {
  448.   /* Points to following fixup.  */
  449.   struct goto_fixup *next;
  450.   /* Points to the insn before the jump insn.
  451.      If more code must be inserted, it goes after this insn.  */
  452.   rtx before_jump;
  453.   /* The LABEL_DECL that this jump is jumping to, or 0
  454.      for break, continue or return.  */
  455.   tree target;
  456.   /* The CODE_LABEL rtx that this is jumping to.  */
  457.   rtx target_rtl;
  458.   /* The outermost stack level that should be restored for this jump.
  459.      Each time a binding contour that resets the stack is exited,
  460.      if the target label is *not* yet defined, this slot is updated.  */
  461.   rtx stack_level;
  462.   /* List of lists of cleanup expressions to be run by this goto.
  463.      There is one element for each block that this goto is within,
  464.      once there are any cleanups at all.
  465.      The TREE_VALUE contains the cleanup list of that block as of the
  466.      time this goto was seen.
  467.      The TREE_ADDRESSABLE flag is 1 for a block that has been exited.  */
  468.   tree cleanup_list_list;
  469. };
  470.  
  471. static struct goto_fixup *goto_fixup_chain;
  472.  
  473. /* Within any binding contour that must restore a stack level,
  474.    all labels are recorded with a chain of these structures.  */
  475.  
  476. struct label_chain
  477. {
  478.   /* Points to following fixup.  */
  479.   struct label_chain *next;
  480.   tree label;
  481. };
  482.  
  483. /* Specify the location in the RTL code of a label BODY,
  484.    which is a LABEL_DECL tree node.
  485.  
  486.    This is used for the kind of label that the user can jump to with a
  487.    goto statement, and for alternatives of a switch or case statement.
  488.    RTL labels generated for loops and conditionals don't go through here;
  489.    they are generated directly at the RTL level, by other functions below.
  490.  
  491.    Note that this has nothing to do with defining label *names*.
  492.    Languages vary in how they do that and what that even means.  */
  493.  
  494. void
  495. expand_label (body)
  496.      tree body;
  497. {
  498.   struct label_chain *p;
  499.  
  500.   do_pending_stack_adjust ();
  501.   emit_label (label_rtx (body));
  502.  
  503.   if (stack_block_stack != 0)
  504.     {
  505.       p = (struct label_chain *) oballoc (sizeof (struct label_chain));
  506.       p->next = stack_block_stack->data.block.label_chain;
  507.       stack_block_stack->data.block.label_chain = p;
  508.       p->label = body;
  509.     }
  510. }
  511.  
  512. /* Generate RTL code for a `goto' statement with target label BODY.
  513.    BODY should be a LABEL_DECL tree node that was or will later be
  514.    defined with `expand_label'.  */
  515.  
  516. void
  517. expand_goto (body)
  518.      tree body;
  519. {
  520.   expand_goto_internal (body, label_rtx (body), 0);
  521. }
  522.  
  523. /* Generate RTL code for a `goto' statement with target label BODY.
  524.    LABEL should be a LABEL_REF.
  525.    LAST_INSN, if non-0, is the rtx we should consider as the last
  526.    insn emitted (for the purposes of cleaning up a return).  */
  527.  
  528. static void
  529. expand_goto_internal (body, label, last_insn)
  530.      tree body;
  531.      rtx label;
  532.      rtx last_insn;
  533. {
  534.   struct nesting *block;
  535.   rtx stack_level = 0;
  536.  
  537.   if (GET_CODE (label) != CODE_LABEL)
  538.     abort ();
  539.  
  540.   /* If label has already been defined, we can tell now
  541.      whether and how we must alter the stack level.  */
  542.  
  543.   if (PREV_INSN (label) != 0)
  544.     {
  545.       /* Find the innermost pending block that contains the label.
  546.      (Check containment by comparing insn-uids.)
  547.      Then restore the outermost stack level within that block,
  548.      and do cleanups of all blocks contained in it.  */
  549.       for (block = block_stack; block; block = block->next)
  550.     {
  551.       if (INSN_UID (block->data.block.first_insn) < INSN_UID (label))
  552.         break;
  553.       if (block->data.block.stack_level != 0)
  554.         stack_level = block->data.block.stack_level;
  555.       /* Execute the cleanups for blocks we are exiting.  */
  556.       if (block->data.block.cleanups != 0)
  557.         {
  558.           expand_cleanups (block->data.block.cleanups, 0);
  559.           do_pending_stack_adjust ();
  560.         }
  561.     }
  562.  
  563.       if (stack_level)
  564.     emit_move_insn (stack_pointer_rtx, stack_level);
  565.  
  566.       if (body != 0 && TREE_PACKED (body))
  567.     error ("jump to `%s' invalidly jumps into binding contour",
  568.            IDENTIFIER_POINTER (DECL_NAME (body)));
  569.     }
  570.   /* Label not yet defined: may need to put this goto
  571.      on the fixup list.  */
  572.   else if (! expand_fixup (body, label, last_insn))
  573.     {
  574.       /* No fixup needed.  Record that the label is the target
  575.      of at least one goto that has no fixup.  */
  576.       if (body != 0)
  577.     TREE_ADDRESSABLE (body) = 1;
  578.     }
  579.  
  580.   emit_jump (label);
  581. }
  582.  
  583. /* Return truth-value of whether there are any cleanups from
  584.    the current binding contour to the end of the current function's
  585.    binding contours.  */
  586. int
  587. any_pending_cleanups ()
  588. {
  589.   struct nesting *block;
  590.  
  591.   if (block_stack->data.block.cleanups == 0
  592.       || block_stack->data.block.outer_cleanups == empty_cleanup_list)
  593.     return 0;
  594.  
  595.   for (block = block_stack->next; block; block = block->next)
  596.     if (block->data.block.cleanups != 0)
  597.       break;
  598.  
  599.   return block != 0;
  600. }
  601.  
  602. /* Generate if necessary a fixup for a goto
  603.    whose target label in tree structure (if any) is TREE_LABEL
  604.    and whose target in rtl is RTL_LABEL.
  605.  
  606.    If LAST_INSN is nonzero, we pretend that the jump appears
  607.    after insn LAST_INSN instead of at the current point in the insn stream.
  608.  
  609.    The fixup will be used later to insert insns at this point
  610.    to restore the stack level as appropriate for the target label.
  611.  
  612.    Value is nonzero if a fixup is made.  */
  613.  
  614. static int
  615. expand_fixup (tree_label, rtl_label, last_insn)
  616.      tree tree_label;
  617.      rtx rtl_label;
  618.      rtx last_insn;
  619. {
  620.   struct nesting *block, *end_block;
  621.  
  622.   /* See if we can recognize which block the label will be output in.
  623.      This is possible in some very common cases.
  624.      If we succeed, set END_BLOCK to that block.
  625.      Otherwise, set it to 0.  */
  626.  
  627.   if (cond_stack
  628.       && (rtl_label == cond_stack->data.cond.else_label
  629.       || rtl_label == cond_stack->data.cond.after_label))
  630.     end_block = cond_stack;
  631.   /* If we are in a loop, recognize certain labels which
  632.      are likely targets.  This reduces the number of fixups
  633.      we need to create.  */
  634.   else if (loop_stack
  635.       && (rtl_label == loop_stack->data.loop.start_label
  636.       || rtl_label == loop_stack->data.loop.end_label
  637.       || rtl_label == loop_stack->data.loop.continue_label))
  638.     end_block = loop_stack;
  639.   else
  640.     end_block = 0;
  641.  
  642.   /* Now set END_BLOCK to the binding level to which we will return.  */
  643.  
  644.   if (end_block)
  645.     {
  646.       struct nesting *next_block = end_block->all;
  647.       block = block_stack;
  648.  
  649.       /* First see if the END_BLOCK is inside the innermost binding level.
  650.      If so, then no cleanups or stack levels are relevant.  */
  651.       while (next_block && next_block != block)
  652.     next_block = next_block->all;
  653.  
  654.       if (next_block)
  655.     return 0;
  656.  
  657.       /* Otherwise, set END_BLOCK to the innermost binding level
  658.      which is outside the relevant control-structure nesting.  */
  659.       next_block = block_stack->next;
  660.       for (block = block_stack; block != end_block; block = block->all)
  661.     if (block == next_block)
  662.       next_block = next_block->next;
  663.       end_block = next_block;
  664.     }
  665.  
  666.   /* Does any containing block have a stack level or cleanups?
  667.      If not, no fixup is needed, and that is the normal case
  668.      (the only case, for standard C).  */
  669.   for (block = block_stack; block != end_block; block = block->next)
  670.     if (block->data.block.stack_level != 0
  671.     || block->data.block.cleanups != 0)
  672.       break;
  673.  
  674.   if (block != end_block)
  675.     {
  676.       /* Ok, a fixup is needed.  Add a fixup to the list of such.  */
  677.       struct goto_fixup *fixup
  678.     = (struct goto_fixup *) oballoc (sizeof (struct goto_fixup));
  679.       /* In case an old stack level is restored, make sure that comes
  680.      after any pending stack adjust.  */
  681.       do_pending_stack_adjust ();
  682.       fixup->before_jump = last_insn ? last_insn : get_last_insn ();
  683.       fixup->target = tree_label;
  684.       fixup->target_rtl = rtl_label;
  685.       fixup->stack_level = 0;
  686.       fixup->cleanup_list_list
  687.     = (((block->data.block.outer_cleanups
  688.          && block->data.block.outer_cleanups != empty_cleanup_list)
  689.         || block->data.block.cleanups)
  690.        ? tree_cons (0, block->data.block.cleanups,
  691.             block->data.block.outer_cleanups)
  692.        : 0);
  693.       fixup->next = goto_fixup_chain;
  694.       goto_fixup_chain = fixup;
  695.     }
  696.  
  697.   return block != 0;
  698. }
  699.  
  700. /* When exiting a binding contour, process all pending gotos requiring fixups.
  701.    THISBLOCK is the structure that describes the block being exited.
  702.    STACK_LEVEL is the rtx for the stack level to restore exiting this contour.
  703.    CLEANUP_LIST is a list of expressions to evaluate on exiting this contour.
  704.    FIRST_INSN is the insn that began this contour.
  705.  
  706.    Gotos that jump out of this contour must restore the
  707.    stack level and do the cleanups before actually jumping.
  708.  
  709.    DONT_JUMP_IN nonzero means report error there is a jump into this
  710.    contour from before the beginning of the contour.
  711.    This is also done if STACK_LEVEL is nonzero.  */
  712.  
  713. static void
  714. fixup_gotos (thisblock, stack_level, cleanup_list, first_insn, dont_jump_in)
  715.      struct nesting *thisblock;
  716.      rtx stack_level;
  717.      tree cleanup_list;
  718.      rtx first_insn;
  719.      int dont_jump_in;
  720. {
  721.   register struct goto_fixup *f, *prev;
  722.  
  723.   /* F is the fixup we are considering; PREV is the previous one.  */
  724.  
  725.   for (prev = 0, f = goto_fixup_chain; f; prev = f, f = f->next)
  726.     {
  727.       /* Test for a fixup that is inactive because it is already handled.  */
  728.       if (f->before_jump == 0)
  729.     {
  730.       /* Delete inactive fixup from the chain, if that is easy to do.  */
  731.       if (prev != 0)
  732.         prev->next = f->next;
  733.     }
  734.       /* Has this fixup's target label been defined?
  735.      If so, we can finalize it.  */
  736.       else if (PREV_INSN (f->target_rtl) != 0)
  737.     {
  738.       /* If this fixup jumped into this contour from before the beginning
  739.          of this contour, report an error.  */
  740.       /* ??? Bug: this does not detect jumping in through intermediate
  741.          blocks that have stack levels or cleanups.
  742.          It detects only a problem with the innermost block
  743.          around the label.  */
  744.       if (f->target != 0
  745.           && (dont_jump_in || stack_level || cleanup_list)
  746.           && INSN_UID (first_insn) > INSN_UID (f->before_jump)
  747.           && ! TREE_ADDRESSABLE (f->target))
  748.         {
  749.           error_with_decl (f->target,
  750.                    "label `%s' used before containing binding contour");
  751.           /* Prevent multiple errors for one label.  */
  752.           TREE_ADDRESSABLE (f->target) = 1;
  753.         }
  754.  
  755.       /* Execute cleanups for blocks this jump exits.  */
  756.       if (f->cleanup_list_list)
  757.         {
  758.           tree lists;
  759.           for (lists = f->cleanup_list_list; lists; lists = TREE_CHAIN (lists))
  760.         /* Marked elements correspond to blocks that have been closed.
  761.            Do their cleanups.  */
  762.         if (TREE_ADDRESSABLE (lists)
  763.             && TREE_VALUE (lists) != 0)
  764.           fixup_cleanups (TREE_VALUE (lists), &f->before_jump);
  765.         }
  766.  
  767.       /* Restore stack level for the biggest contour that this
  768.          jump jumps out of.  */
  769.       if (f->stack_level)
  770.         emit_insn_after (gen_move_insn (stack_pointer_rtx, f->stack_level),
  771.                  f->before_jump);
  772.       f->before_jump = 0;
  773.     }
  774.       /* Label has still not appeared.  If we are exiting a block with
  775.      a stack level to restore, mark this stack level as needing
  776.      restoration when the fixup is later finalized.
  777.      Also mark the cleanup_list_list element for F
  778.      that corresponds to this block, so that ultimately
  779.      this block's cleanups will be executed by the code above.  */
  780.       /* Note: if THISBLOCK == 0 and we have a label that hasn't appeared,
  781.      it means the label is undefined.  That's erroneous, but possible.  */
  782.       else if (thisblock != 0)
  783.     {
  784.       tree lists = f->cleanup_list_list;
  785.       for (; lists; lists = TREE_CHAIN (lists))
  786.         /* If the following elt. corresponds to our containing block
  787.            then the elt. must be for this block.  */
  788.         if (TREE_CHAIN (lists) == thisblock->data.block.outer_cleanups)
  789.           TREE_ADDRESSABLE (lists) = 1;
  790.  
  791.       if (stack_level)
  792.         f->stack_level = stack_level;
  793.     }
  794.     }
  795. }
  796.  
  797. /* Generate RTL for an asm statement (explicit assembler code).
  798.    BODY is a STRING_CST node containing the assembler code text.  */
  799.  
  800. void
  801. expand_asm (body)
  802.      tree body;
  803. {
  804.   emit_insn (gen_rtx (ASM_INPUT, VOIDmode,
  805.               TREE_STRING_POINTER (body)));
  806.   last_expr_type = 0;
  807. }
  808.  
  809. /* Generate RTL for an asm statement with arguments.
  810.    STRING is the instruction template.
  811.    OUTPUTS is a list of output arguments (lvalues); INPUTS a list of inputs.
  812.    Each output or input has an expression in the TREE_VALUE and
  813.    a constraint-string in the TREE_PURPOSE.
  814.    CLOBBERS is a list of STRING_CST nodes each naming a hard register
  815.    that is clobbered by this insn.
  816.  
  817.    Not all kinds of lvalue that may appear in OUTPUTS can be stored directly.
  818.    Some elements of OUTPUTS may be replaced with trees representing temporary
  819.    values.  The caller should copy those temporary values to the originally
  820.    specified lvalues.
  821.  
  822.    VOL nonzero means the insn is volatile; don't optimize it.  */
  823.  
  824. void
  825. expand_asm_operands (string, outputs, inputs, clobbers, vol, filename, line)
  826.      tree string, outputs, inputs, clobbers;
  827.      int vol;
  828.      char *filename;
  829.      int line;
  830. {
  831.   rtvec argvec, constraints;
  832.   rtx body;
  833.   int ninputs = list_length (inputs);
  834.   int noutputs = list_length (outputs);
  835.   int nclobbers = list_length (clobbers);
  836.   tree tail;
  837.   register int i;
  838.   /* Vector of RTX's of evaluated output operands.  */
  839.   rtx *output_rtx = (rtx *) alloca (noutputs * sizeof (rtx));
  840.   /* The insn we have emitted.  */
  841.   rtx insn;
  842.  
  843.   last_expr_type = 0;
  844.  
  845.   for (i = 0, tail = outputs; tail; tail = TREE_CHAIN (tail), i++)
  846.     {
  847.       tree val = TREE_VALUE (tail);
  848.       int j;
  849.       int found_equal;
  850.  
  851.       /* If there's an erroneous arg, emit no insn.  */
  852.       if (TREE_TYPE (val) == error_mark_node)
  853.     return;
  854.  
  855.       /* Make sure constraint has `=' and does not have `+'.  */
  856.  
  857.       found_equal = 0;
  858.       for (j = 0; j < TREE_STRING_LENGTH (TREE_PURPOSE (tail)); j++)
  859.     {
  860.       if (TREE_STRING_POINTER (TREE_PURPOSE (tail))[j] == '+')
  861.         {
  862.           error ("output operand constraint contains `+'");
  863.           return;
  864.         }
  865.       if (TREE_STRING_POINTER (TREE_PURPOSE (tail))[j] == '=')
  866.         found_equal = 1;
  867.     }
  868.       if (! found_equal)
  869.     {
  870.       error ("output operand constraint lacks `='");
  871.       return;
  872.     }
  873.  
  874.       /* If an output operand is not a variable or indirect ref,
  875.      create a SAVE_EXPR which is a pseudo-reg
  876.      to act as an intermediate temporary.
  877.      Make the asm insn write into that, then copy it to
  878.      the real output operand.  */
  879.  
  880.       if (TREE_CODE (val) != VAR_DECL
  881.       && TREE_CODE (val) != PARM_DECL
  882.       && TREE_CODE (val) != INDIRECT_REF)
  883.     {
  884.       rtx reg = gen_reg_rtx (TYPE_MODE (TREE_TYPE (val)));
  885.       /* `build' isn't safe; it really expects args to be trees.  */
  886.       tree t = build_nt (SAVE_EXPR, val, reg);
  887.  
  888.       save_expr_regs = gen_rtx (EXPR_LIST, VOIDmode, reg, save_expr_regs);
  889.       TREE_VALUE (tail) = t;
  890.       TREE_TYPE (t) = TREE_TYPE (val);
  891.     }
  892.       output_rtx[i] = expand_expr (TREE_VALUE (tail), 0, VOIDmode, 0);
  893.     }
  894.  
  895.   if (ninputs + noutputs > MAX_RECOG_OPERANDS)
  896.     {
  897.       error ("more than %d operands in `asm'", MAX_RECOG_OPERANDS);
  898.       return;
  899.     }
  900.  
  901.   /* Make vectors for the expression-rtx and constraint strings.  */
  902.  
  903.   argvec = rtvec_alloc (ninputs);
  904.   constraints = rtvec_alloc (ninputs);
  905.  
  906.   body = gen_rtx (ASM_OPERANDS, VOIDmode,
  907.           TREE_STRING_POINTER (string), "", 0, argvec, constraints,
  908.           filename, line);
  909.   MEM_VOLATILE_P (body) = vol;
  910.  
  911.   /* Eval the inputs and put them into ARGVEC.
  912.      Put their constraints into ASM_INPUTs and store in CONSTRAINTS.  */
  913.  
  914.   i = 0;
  915.   for (tail = inputs; tail; tail = TREE_CHAIN (tail))
  916.     {
  917.       int j;
  918.  
  919.       /* If there's an erroneous arg, emit no insn,
  920.      because the ASM_INPUT would get VOIDmode
  921.      and that could cause a crash in reload.  */
  922.       if (TREE_TYPE (TREE_VALUE (tail)) == error_mark_node)
  923.     return;
  924.       if (TREE_PURPOSE (tail) == NULL_TREE)
  925.     {
  926.       error ("hard register `%s' listed as input operand to `asm'",
  927.          TREE_STRING_POINTER (TREE_VALUE (tail)) );
  928.       return;
  929.     }
  930.  
  931.       /* Make sure constraint has neither `=' nor `+'.  */
  932.  
  933.       for (j = 0; j < TREE_STRING_LENGTH (TREE_PURPOSE (tail)); j++)
  934.     if (TREE_STRING_POINTER (TREE_PURPOSE (tail))[j] == '='
  935.         || TREE_STRING_POINTER (TREE_PURPOSE (tail))[j] == '+')
  936.       {
  937.         error ("input operand constraint contains `%c'",
  938.            TREE_STRING_POINTER (TREE_PURPOSE (tail))[j]);
  939.         return;
  940.       }
  941.  
  942.       XVECEXP (body, 3, i)      /* argvec */
  943.     = expand_expr (TREE_VALUE (tail), 0, VOIDmode, 0);
  944.       XVECEXP (body, 4, i)      /* constraints */
  945.     = gen_rtx (ASM_INPUT, TYPE_MODE (TREE_TYPE (TREE_VALUE (tail))),
  946.            TREE_STRING_POINTER (TREE_PURPOSE (tail)));
  947.       i++;
  948.     }
  949.  
  950.   /* Protect all the operands from the queue,
  951.      now that they have all been evaluated.  */
  952.  
  953.   for (i = 0; i < ninputs; i++)
  954.     XVECEXP (body, 3, i) = protect_from_queue (XVECEXP (body, 3, i), 0);
  955.  
  956.   for (i = 0; i < noutputs; i++)
  957.     output_rtx[i] = protect_from_queue (output_rtx[i], 1);
  958.  
  959.   /* Now, for each output, construct an rtx
  960.      (set OUTPUT (asm_operands INSN OUTPUTNUMBER OUTPUTCONSTRAINT
  961.                    ARGVEC CONSTRAINTS))
  962.      If there is more than one, put them inside a PARALLEL.  */
  963.  
  964.   if (noutputs == 1 && nclobbers == 0)
  965.     {
  966.       XSTR (body, 1) = TREE_STRING_POINTER (TREE_PURPOSE (outputs));
  967.       insn = emit_insn (gen_rtx (SET, VOIDmode, output_rtx[0], body));
  968.     }
  969.   else if (noutputs == 0 && nclobbers == 0)
  970.     {
  971.       /* No output operands: put in a raw ASM_OPERANDS rtx.  */
  972.       insn = emit_insn (body);
  973.     }
  974.   else
  975.     {
  976.       rtx obody = body;
  977.       int num = noutputs;
  978.       if (num == 0) num = 1;
  979.       body = gen_rtx (PARALLEL, VOIDmode, rtvec_alloc (num + nclobbers));
  980.  
  981.       /* For each output operand, store a SET.  */
  982.  
  983.       for (i = 0, tail = outputs; tail; tail = TREE_CHAIN (tail), i++)
  984.     {
  985.       XVECEXP (body, 0, i)
  986.         = gen_rtx (SET, VOIDmode,
  987.                output_rtx[i],
  988.                gen_rtx (ASM_OPERANDS, VOIDmode,
  989.                 TREE_STRING_POINTER (string),
  990.                 TREE_STRING_POINTER (TREE_PURPOSE (tail)),
  991.                 i, argvec, constraints,
  992.                 filename, line));
  993.       MEM_VOLATILE_P (SET_SRC (XVECEXP (body, 0, i))) = vol;
  994.     }
  995.  
  996.       /* If there are no outputs (but there are some clobbers)
  997.      store the bare ASM_OPERANDS into the PARALLEL.  */
  998.  
  999.       if (i == 0)
  1000.     XVECEXP (body, 0, i++) = obody;
  1001.  
  1002.       /* Store (clobber REG) for each clobbered register specified.  */
  1003.  
  1004.       for (tail = clobbers; tail; tail = TREE_CHAIN (tail), i++)
  1005.     {
  1006.       int j;
  1007.       char *regname = TREE_STRING_POINTER (TREE_VALUE (tail));
  1008.       extern char *reg_names[];
  1009.           
  1010.       for (j = 0; j < FIRST_PSEUDO_REGISTER; j++)
  1011.         if (!strcmp (regname, reg_names[j]))
  1012.           break;
  1013.           
  1014.       if (j == FIRST_PSEUDO_REGISTER)
  1015.         {
  1016.           error ("unknown register name `%s' in `asm'", regname);
  1017.           return;
  1018.         }
  1019.  
  1020.       /* Use QImode since that's guaranteed to clobber just one reg.  */
  1021.       XVECEXP (body, 0, i)
  1022.         = gen_rtx (CLOBBER, VOIDmode, gen_rtx (REG, QImode, j));
  1023.     }
  1024.  
  1025.       insn = emit_insn (body);
  1026.     }
  1027.  
  1028.   last_expr_type = 0;
  1029. }
  1030.  
  1031. /* Nonzero if within a ({...}) grouping, in which case we must
  1032.    always compute a value for each expr-stmt in case it is the last one.  */
  1033.  
  1034. int expr_stmts_for_value;
  1035.  
  1036. /* Generate RTL to evaluate the expression EXP
  1037.    and remember it in case this is the VALUE in a ({... VALUE; }) constr.  */
  1038.  
  1039. void
  1040. expand_expr_stmt (exp)
  1041.      tree exp;
  1042. {
  1043.   /* If -W, warn about statements with no side effects,
  1044.      except inside a ({...}) where they may be useful.  */
  1045.   if (expr_stmts_for_value == 0 && exp != error_mark_node)
  1046.     {
  1047.       if (! TREE_VOLATILE (exp) && (extra_warnings || warn_unused))
  1048.     warning_with_file_and_line (emit_filename, emit_lineno,
  1049.                     "statement with no effect");
  1050.       else if (warn_unused)
  1051.     warn_if_unused_value (exp);
  1052.     }
  1053.   last_expr_type = TREE_TYPE (exp);
  1054.   if (! flag_syntax_only)
  1055.     last_expr_value = expand_expr (exp, expr_stmts_for_value ? 0 : const0_rtx,
  1056.                    VOIDmode, 0);
  1057.   emit_queue ();
  1058. }
  1059.  
  1060. /* Warn if EXP contains any computations whose results are not used.
  1061.    Return 1 if a warning is printed; 0 otherwise.  */
  1062.  
  1063. static int
  1064. warn_if_unused_value (exp)
  1065.      tree exp;
  1066. {
  1067.   switch (TREE_CODE (exp))
  1068.     {
  1069.     case PREINCREMENT_EXPR:
  1070.     case POSTINCREMENT_EXPR:
  1071.     case PREDECREMENT_EXPR:
  1072.     case POSTDECREMENT_EXPR:
  1073.     case MODIFY_EXPR:
  1074.     case INIT_EXPR:
  1075.     case NEW_EXPR:
  1076.     case CALL_EXPR:
  1077.     case METHOD_CALL_EXPR:
  1078.     case RTL_EXPR:
  1079.     case WRAPPER_EXPR:
  1080.     case ANTI_WRAPPER_EXPR:
  1081.     case WITH_CLEANUP_EXPR:
  1082.       /* We don't warn about COND_EXPR because it may be a useful
  1083.      construct if either arm contains a side effect.  */
  1084.     case COND_EXPR:
  1085.       return 0;
  1086.  
  1087.       /* These kinds of exprs are really stmts.  What to do?  */
  1088.     case LOOP_STMT:
  1089.     case LET_STMT:
  1090.     case IF_STMT:
  1091.       return 0;
  1092.  
  1093.     case TRUTH_ORIF_EXPR:
  1094.     case TRUTH_ANDIF_EXPR:
  1095.       /* In && or ||, warn if 2nd operand has no side effect.  */
  1096.       return warn_if_unused_value (TREE_OPERAND (exp, 1));
  1097.  
  1098.     case COMPOUND_EXPR:
  1099.       if (warn_if_unused_value (TREE_OPERAND (exp, 0)))
  1100.     return 1;
  1101.       return warn_if_unused_value (TREE_OPERAND (exp, 1));
  1102.  
  1103.     case NOP_EXPR:
  1104.     case CONVERT_EXPR:
  1105.       /* Don't warn about values cast to void.  */
  1106.       if (TREE_TYPE (exp) == void_type_node)
  1107.     return 0;
  1108.       /* Assignment to a cast results in a cast of a modify.
  1109.      Don't complain about that.  */
  1110.       if (TREE_CODE (TREE_OPERAND (exp, 0)) == MODIFY_EXPR)
  1111.     return 0;
  1112.  
  1113.     default:
  1114.       warning_with_file_and_line (emit_filename, emit_lineno,
  1115.                   "value computed is not used");
  1116.       return 1;
  1117.     }
  1118. }
  1119.  
  1120. /* Clear out the memory of the last expression evaluated.  */
  1121.  
  1122. void
  1123. clear_last_expr ()
  1124. {
  1125.   last_expr_type = 0;
  1126. }
  1127.  
  1128. /* Begin a statement which will return a value.
  1129.    Return the RTL_EXPR for this statement expr.
  1130.    The caller must save that value and pass it to expand_end_stmt_expr.  */
  1131.  
  1132. tree
  1133. expand_start_stmt_expr ()
  1134. {
  1135.   rtx save = start_sequence ();
  1136.   /* Make the RTL_EXPR node temporary, not momentary,
  1137.      so that rtl_expr_chain doesn't become garbage.  */
  1138.   int momentary = suspend_momentary ();
  1139.   tree t = make_node (RTL_EXPR);
  1140.   resume_momentary (momentary);
  1141.   RTL_EXPR_RTL (t) = save;
  1142.   NO_DEFER_POP;
  1143.   expr_stmts_for_value++;
  1144.   return t;
  1145. }
  1146.  
  1147. /* Restore the previous state at the end of a statement that returns a value.
  1148.    Returns a tree node representing the statement's value and the
  1149.    insns to compute the value.
  1150.  
  1151.    The nodes of that expression have been freed by now, so we cannot use them.
  1152.    But we don't want to do that anyway; the expression has already been
  1153.    evaluated and now we just want to use the value.  So generate a RTL_EXPR
  1154.    with the proper type and RTL value.
  1155.  
  1156.    If the last substatement was not an expression,
  1157.    return something with type `void'.  */
  1158.  
  1159. tree
  1160. expand_end_stmt_expr (t)
  1161.      tree t;
  1162. {
  1163.   rtx saved = RTL_EXPR_RTL (t);
  1164.  
  1165.   OK_DEFER_POP;
  1166.  
  1167.   if (last_expr_type == 0)
  1168.     {
  1169.       last_expr_type = void_type_node;
  1170.       last_expr_value = const0_rtx;
  1171.     }
  1172.   TREE_TYPE (t) = last_expr_type;
  1173.   RTL_EXPR_RTL (t) = last_expr_value;
  1174.   RTL_EXPR_SEQUENCE (t) = get_insns ();
  1175.  
  1176.   rtl_expr_chain = tree_cons (NULL_TREE, t, rtl_expr_chain);
  1177.  
  1178.   end_sequence (saved);
  1179.  
  1180.   /* Don't consider deleting this expr or containing exprs at tree level.  */
  1181.   TREE_VOLATILE (t) = 1;
  1182.   /* Propagate volatility of the actual RTL expr.  */
  1183.   TREE_THIS_VOLATILE (t) = volatile_refs_p (last_expr_value);
  1184.  
  1185.   last_expr_type = 0;
  1186.   expr_stmts_for_value--;
  1187.  
  1188.   return t;
  1189. }
  1190.  
  1191. int
  1192. in_try_block (level)
  1193.      int level;
  1194. {
  1195.   struct nesting *n = except_stack;
  1196.   while (1)
  1197.     {
  1198.       while (n && n->data.except_stmt.after_label != 0)
  1199.     n = n->next;
  1200.       if (n == 0)
  1201.     return 0;
  1202.       if (level == 0)
  1203.     return n != 0;
  1204.       level--;
  1205.       n = n->next;
  1206.     }
  1207. }
  1208.  
  1209. int
  1210. in_except_block (level)
  1211.      int level;
  1212. {
  1213.   struct nesting *n = except_stack;
  1214.   while (1)
  1215.     {
  1216.       while (n && n->data.except_stmt.after_label == 0)
  1217.     n = n->next;
  1218.       if (n == 0)
  1219.     return 0;
  1220.       if (level == 0)
  1221.     return n != 0;
  1222.       level--;
  1223.       n = n->next;
  1224.     }
  1225. }
  1226.  
  1227. int
  1228. in_exception_handler (level)
  1229.      int level;
  1230. {
  1231.   struct nesting *n = except_stack;
  1232.   while (n && level--)
  1233.     n = n->next;
  1234.   return n != 0;
  1235. }
  1236.  
  1237. int
  1238. expand_raise (ex)
  1239.      tree ex;
  1240. {
  1241.   tree *raises_ptr;
  1242.  
  1243.   if (except_stack == 0)
  1244.     return 0;
  1245.   raises_ptr = &except_stack->data.except_stmt.raised;
  1246.   if (! value_member (ex, *raises_ptr))
  1247.     *raises_ptr = tree_cons (NULL_TREE, ex, *raises_ptr);
  1248.   return 1;
  1249. }
  1250.  
  1251. /* Generate RTL for the start of a try block.
  1252.  
  1253.    TRY_CLAUSE is the condition to test to enter the try block.  */
  1254. void
  1255. expand_start_try (try_clause, exitflag, escapeflag)
  1256.      tree try_clause;
  1257.      int exitflag;
  1258.      int escapeflag;
  1259. {
  1260.   struct nesting *thishandler
  1261.     = (struct nesting *) obstack_alloc (&stmt_obstack, sizeof (struct nesting));
  1262.  
  1263.   /* Make an entry on cond_stack for the cond we are entering.  */
  1264.  
  1265.   thishandler->next = except_stack;
  1266.   thishandler->all = nesting_stack;
  1267.   thishandler->depth = ++nesting_depth;
  1268.   thishandler->data.except_stmt.raised = 0;
  1269.   thishandler->data.except_stmt.handled = 0;
  1270.   thishandler->data.except_stmt.first_insn = get_insns ();
  1271.   thishandler->data.except_stmt.except_label = gen_label_rtx ();
  1272.   thishandler->data.except_stmt.unhandled_label = 0;
  1273.   thishandler->data.except_stmt.after_label = 0;
  1274.   thishandler->data.except_stmt.escape_label
  1275.     = escapeflag ? thishandler->data.except_stmt.except_label : 0;
  1276.   thishandler->exit_label = exitflag ? gen_label_rtx () : 0;
  1277.   except_stack = thishandler;
  1278.   nesting_stack = thishandler;
  1279.  
  1280.   do_jump (try_clause, thishandler->data.except_stmt.except_label, NULL);
  1281. }
  1282.  
  1283. /* End of a TRY block.  Nothing to do for now.  */
  1284. void
  1285. expand_end_try ()
  1286. {
  1287.   except_stack->data.except_stmt.after_label = gen_label_rtx ();
  1288.   expand_goto_internal (NULL, except_stack->data.except_stmt.after_label, 0);
  1289. }
  1290.  
  1291. void
  1292. expand_start_except (exitflag, escapeflag)
  1293.      int exitflag;
  1294.      int escapeflag;
  1295. {
  1296.   if (exitflag)
  1297.     {
  1298.       struct nesting *n;
  1299.       /* An `exit' from catch clauses goes out to next exit level,
  1300.      if there is one.  Otherwise, it just goes to the end
  1301.      of the construct.  */
  1302.       for (n = except_stack->next; n; n = n->next)
  1303.     if (n->exit_label != 0)
  1304.       {
  1305.         except_stack->exit_label = n->exit_label;
  1306.         break;
  1307.       }
  1308.       if (n == 0)
  1309.     except_stack->exit_label = except_stack->data.except_stmt.after_label;
  1310.     }
  1311.   if (escapeflag)
  1312.     {
  1313.       struct nesting *n;
  1314.       /* An `escape' from catch clauses goes out to next escape level,
  1315.      if there is one.  Otherwise, it just goes to the end
  1316.      of the construct.  */
  1317.       for (n = except_stack->next; n; n = n->next)
  1318.     if (n->data.except_stmt.escape_label != 0)
  1319.       {
  1320.         except_stack->data.except_stmt.escape_label
  1321.           = n->data.except_stmt.escape_label;
  1322.         break;
  1323.       }
  1324.       if (n == 0)
  1325.     except_stack->data.except_stmt.escape_label
  1326.       = except_stack->data.except_stmt.after_label;
  1327.     }
  1328.   do_pending_stack_adjust ();
  1329.   emit_label (except_stack->data.except_stmt.except_label);
  1330. }
  1331.  
  1332. int
  1333. expand_escape_except ()
  1334. {
  1335.   struct nesting *n;
  1336.   last_expr_type = 0;
  1337.   for (n = except_stack; n; n = n->next)
  1338.     if (n->data.except_stmt.escape_label != 0)
  1339.       {
  1340.     expand_goto_internal (0, n->data.except_stmt.escape_label, 0);
  1341.     return 1;
  1342.       }
  1343.  
  1344.   return 0;
  1345. }
  1346.  
  1347. tree
  1348. expand_end_except ()
  1349. {
  1350.   struct nesting *n;
  1351.   tree raised = NULL_TREE;
  1352.  
  1353.   do_pending_stack_adjust ();
  1354.   emit_label (except_stack->data.except_stmt.after_label);
  1355.  
  1356.   n = except_stack->next;
  1357.   if (n)
  1358.     {
  1359.       /* Propagate exceptions raised but not handled to next
  1360.      highest level.  */
  1361.       tree handled = except_stack->data.except_stmt.raised;
  1362.       if (handled != void_type_node)
  1363.     {
  1364.       tree prev = NULL_TREE;
  1365.       raised = except_stack->data.except_stmt.raised;
  1366.       while (handled)
  1367.         {
  1368.           tree this_raise;
  1369.           for (this_raise = raised, prev = 0; this_raise;
  1370.            this_raise = TREE_CHAIN (this_raise))
  1371.         {
  1372.           if (value_member (TREE_VALUE (this_raise), handled))
  1373.             {
  1374.               if (prev)
  1375.             TREE_CHAIN (prev) = TREE_CHAIN (this_raise);
  1376.               else
  1377.             {
  1378.               raised = TREE_CHAIN (raised);
  1379.               if (raised == NULL_TREE)
  1380.                 goto nada;
  1381.             }
  1382.             }
  1383.           else
  1384.             prev = this_raise;
  1385.         }
  1386.           handled = TREE_CHAIN (handled);
  1387.         }
  1388.       if (prev == NULL_TREE)
  1389.         prev = raised;
  1390.       if (prev)
  1391.         TREE_CHAIN (prev) = n->data.except_stmt.raised;
  1392.     nada:
  1393.       n->data.except_stmt.raised = raised;
  1394.     }
  1395.     }
  1396.  
  1397.   POPSTACK (except_stack);
  1398.   last_expr_type = 0;
  1399.   return raised;
  1400. }
  1401.  
  1402. int
  1403. expand_catch (ex)
  1404.      tree ex;
  1405. {
  1406.   tree *raises_ptr;
  1407.  
  1408.   if (except_stack == 0)
  1409.     return 0;
  1410.   raises_ptr = &except_stack->data.except_stmt.handled;
  1411.   if (*raises_ptr != void_type_node
  1412.       && ex != NULL_TREE
  1413.       && ! value_member (ex, *raises_ptr))
  1414.     *raises_ptr = tree_cons (NULL_TREE, ex, *raises_ptr);
  1415.   return 1;
  1416. }
  1417.  
  1418. int
  1419. expand_catch_default ()
  1420. {
  1421.   if (except_stack == 0)
  1422.     return 0;
  1423.   except_stack->data.except_stmt.handled = void_type_node;
  1424. }
  1425.  
  1426. int
  1427. expand_end_catch ()
  1428. {
  1429.   if (except_stack == 0 || except_stack->data.except_stmt.after_label == 0)
  1430.     return 0;
  1431.   expand_goto_internal (0, except_stack->data.except_stmt.after_label, 0);
  1432.   return 1;
  1433. }
  1434.  
  1435. /* Generate RTL for the start of an if-then.  COND is the expression
  1436.    whose truth should be tested.
  1437.  
  1438.    If EXITFLAG is nonzero, this conditional is visible to
  1439.    `exit_something'.  */
  1440.  
  1441. void
  1442. expand_start_cond (cond, exitflag)
  1443.      tree cond;
  1444.      int exitflag;
  1445. {
  1446.   struct nesting *thiscond
  1447.     = (struct nesting *) obstack_alloc (&stmt_obstack, sizeof (struct nesting));
  1448.  
  1449.   /* Make an entry on cond_stack for the cond we are entering.  */
  1450.  
  1451.   thiscond->next = cond_stack;
  1452.   thiscond->all = nesting_stack;
  1453.   thiscond->depth = ++nesting_depth;
  1454.   thiscond->data.cond.after_label = 0;
  1455.   thiscond->data.cond.else_label = gen_label_rtx ();
  1456.   thiscond->exit_label = exitflag ? thiscond->data.cond.else_label : 0;
  1457.   cond_stack = thiscond;
  1458.   nesting_stack = thiscond;
  1459.  
  1460.   do_jump (cond, thiscond->data.cond.else_label, NULL);
  1461. }
  1462.  
  1463. /* Generate RTL for the end of an if-then with no else-clause.
  1464.    Pop the record for it off of cond_stack.  */
  1465.  
  1466. void
  1467. expand_end_cond ()
  1468. {
  1469.   struct nesting *thiscond = cond_stack;
  1470.  
  1471.   do_pending_stack_adjust ();
  1472.   emit_label (thiscond->data.cond.else_label);
  1473.  
  1474.   POPSTACK (cond_stack);
  1475.   last_expr_type = 0;
  1476. }
  1477.  
  1478. /* Generate RTL between the then-clause and the else-clause
  1479.    of an if-then-else.  */
  1480.  
  1481. void
  1482. expand_start_else ()
  1483. {
  1484.   cond_stack->data.cond.after_label = gen_label_rtx ();
  1485.   if (cond_stack->exit_label != 0)
  1486.     cond_stack->exit_label = cond_stack->data.cond.after_label;
  1487.   emit_jump (cond_stack->data.cond.after_label);
  1488.   if (cond_stack->data.cond.else_label)
  1489.     emit_label (cond_stack->data.cond.else_label);
  1490. }
  1491.  
  1492. /* Generate RTL for the end of an if-then-else.
  1493.    Pop the record for it off of cond_stack.  */
  1494.  
  1495. void
  1496. expand_end_else ()
  1497. {
  1498.   struct nesting *thiscond = cond_stack;
  1499.  
  1500.   do_pending_stack_adjust ();
  1501.   /* Note: a syntax error can cause this to be called
  1502.      without first calling `expand_start_else'.  */
  1503.   if (thiscond->data.cond.after_label)
  1504.     emit_label (thiscond->data.cond.after_label);
  1505.  
  1506.   POPSTACK (cond_stack);
  1507.   last_expr_type = 0;
  1508. }
  1509.  
  1510. /* Generate RTL for the start of a loop.  EXIT_FLAG is nonzero if this
  1511.    loop should be exited by `exit_something'.  This is a loop for which
  1512.    `expand_continue' will jump to the top of the loop.
  1513.  
  1514.    Make an entry on loop_stack to record the labels associated with
  1515.    this loop.  */
  1516.  
  1517. void
  1518. expand_start_loop (exit_flag)
  1519.      int exit_flag;
  1520. {
  1521.   register struct nesting *thisloop
  1522.     = (struct nesting *) obstack_alloc (&stmt_obstack, sizeof (struct nesting));
  1523.  
  1524.   /* Make an entry on loop_stack for the loop we are entering.  */
  1525.  
  1526.   thisloop->next = loop_stack;
  1527.   thisloop->all = nesting_stack;
  1528.   thisloop->depth = ++nesting_depth;
  1529.   thisloop->data.loop.start_label = gen_label_rtx ();
  1530.   thisloop->data.loop.end_label = gen_label_rtx ();
  1531.   thisloop->data.loop.continue_label = thisloop->data.loop.start_label;
  1532.   thisloop->exit_label = exit_flag ? thisloop->data.loop.end_label : 0;
  1533.   loop_stack = thisloop;
  1534.   nesting_stack = thisloop;
  1535.  
  1536.   do_pending_stack_adjust ();
  1537.   emit_queue ();
  1538.   emit_note (0, NOTE_INSN_LOOP_BEG);
  1539.   emit_label (thisloop->data.loop.start_label);
  1540. }
  1541.  
  1542. /* Like expand_start_loop but for a loop where the continuation point
  1543.    (for expand_continue_loop) will be specified explicitly.  */
  1544.  
  1545. void
  1546. expand_start_loop_continue_elsewhere (exit_flag)
  1547.      int exit_flag;
  1548. {
  1549.   expand_start_loop (exit_flag);
  1550.   loop_stack->data.loop.continue_label = gen_label_rtx ();
  1551. }
  1552.  
  1553. /* Specify the continuation point for a loop started with
  1554.    expand_start_loop_continue_elsewhere.
  1555.    Use this at the point in the code to which a continue statement
  1556.    should jump.  */
  1557.  
  1558. void
  1559. expand_loop_continue_here ()
  1560. {
  1561.   do_pending_stack_adjust ();
  1562.   emit_note (0, NOTE_INSN_LOOP_CONT);
  1563.   emit_label (loop_stack->data.loop.continue_label);
  1564. }
  1565.  
  1566. /* Finish a loop.  Generate a jump back to the top and the loop-exit label.
  1567.    Pop the block off of loop_stack.  */
  1568.  
  1569. void
  1570. expand_end_loop ()
  1571. {
  1572.   register rtx insn = get_last_insn ();
  1573.   register rtx start_label = loop_stack->data.loop.start_label;
  1574.  
  1575.   do_pending_stack_adjust ();
  1576.  
  1577.   /* If optimizing, perhaps reorder the loop.  If the loop
  1578.      starts with a conditional exit, roll that to the end
  1579.      where it will optimize together with the jump back.  */
  1580.   if (optimize
  1581.       &&
  1582.       ! (GET_CODE (insn) == JUMP_INSN
  1583.      && GET_CODE (PATTERN (insn)) == SET
  1584.      && SET_DEST (PATTERN (insn)) == pc_rtx
  1585.      && GET_CODE (SET_SRC (PATTERN (insn))) == IF_THEN_ELSE))
  1586.     {
  1587.       /* Scan insns from the top of the loop looking for a qualified
  1588.      conditional exit.  */
  1589.       for (insn = loop_stack->data.loop.start_label; insn; insn= NEXT_INSN (insn))
  1590.     if (GET_CODE (insn) == JUMP_INSN && GET_CODE (PATTERN (insn)) == SET
  1591.         && SET_DEST (PATTERN (insn)) == pc_rtx
  1592.         && GET_CODE (SET_SRC (PATTERN (insn))) == IF_THEN_ELSE
  1593.         &&
  1594.         ((GET_CODE (XEXP (SET_SRC (PATTERN (insn)), 1)) == LABEL_REF
  1595.           && (XEXP (XEXP (SET_SRC (PATTERN (insn)), 1), 0)
  1596.           == loop_stack->data.loop.end_label))
  1597.          ||
  1598.          (GET_CODE (XEXP (SET_SRC (PATTERN (insn)), 2)) == LABEL_REF
  1599.           && (XEXP (XEXP (SET_SRC (PATTERN (insn)), 2), 0)
  1600.           == loop_stack->data.loop.end_label))))
  1601.       break;
  1602.       if (insn != 0)
  1603.     {
  1604.       /* We found one.  Move everything from there up
  1605.          to the end of the loop, and add a jump into the loop
  1606.          to jump to there.  */
  1607.       register rtx newstart_label = gen_label_rtx ();
  1608.  
  1609.       emit_label_after (newstart_label, PREV_INSN (start_label));
  1610.       reorder_insns (start_label, insn, get_last_insn ());
  1611.       emit_jump_insn_after (gen_jump (start_label), PREV_INSN (newstart_label));
  1612.       emit_barrier_after (PREV_INSN (newstart_label));
  1613.       start_label = newstart_label;
  1614.     }
  1615.     }
  1616.  
  1617.   emit_jump (start_label);
  1618.   emit_note (0, NOTE_INSN_LOOP_END);
  1619.   emit_label (loop_stack->data.loop.end_label);
  1620.  
  1621.   POPSTACK (loop_stack);
  1622.  
  1623.   last_expr_type = 0;
  1624. }
  1625.  
  1626. /* Generate a jump to the current loop's continue-point.
  1627.    This is usually the top of the loop, but may be specified
  1628.    explicitly elsewhere.  If not currently inside a loop,
  1629.    return 0 and do nothing; caller will print an error message.  */
  1630.  
  1631. int
  1632. expand_continue_loop ()
  1633. {
  1634.   last_expr_type = 0;
  1635.   if (loop_stack == 0)
  1636.     return 0;
  1637.   expand_goto_internal (0, loop_stack->data.loop.continue_label, 0);
  1638.   return 1;
  1639. }
  1640.  
  1641. /* Generate a jump to exit the current loop.  If not currently inside a loop,
  1642.    return 0 and do nothing; caller will print an error message.  */
  1643.  
  1644. int
  1645. expand_exit_loop ()
  1646. {
  1647.   last_expr_type = 0;
  1648.   if (loop_stack == 0)
  1649.     return 0;
  1650.   expand_goto_internal (0, loop_stack->data.loop.end_label, 0);
  1651.   return 1;
  1652. }
  1653.  
  1654. /* Generate a conditional jump to exit the current loop if COND
  1655.    evaluates to zero.  If not currently inside a loop,
  1656.    return 0 and do nothing; caller will print an error message.  */
  1657.  
  1658. int
  1659. expand_exit_loop_if_false (cond)
  1660.      tree cond;
  1661. {
  1662.   last_expr_type = 0;
  1663.   if (loop_stack == 0)
  1664.     return 0;
  1665.   do_jump (cond, loop_stack->data.loop.end_label, NULL);
  1666.   return 1;
  1667. }
  1668.  
  1669. /* Return non-zero if currently inside a loop.  */
  1670.  
  1671. int
  1672. inside_loop ()
  1673. {
  1674.   return loop_stack != 0;
  1675. }
  1676.  
  1677. /* Generate a jump to exit the current loop, conditional, binding contour
  1678.    or case statement.  Not all such constructs are visible to this function,
  1679.    only those started with EXIT_FLAG nonzero.  Individual languages use
  1680.    the EXIT_FLAG parameter to control which kinds of constructs you can
  1681.    exit this way.
  1682.  
  1683.    If not currently inside anything that can be exited,
  1684.    return 0 and do nothing; caller will print an error message.  */
  1685.  
  1686. int
  1687. expand_exit_something ()
  1688. {
  1689.   struct nesting *n;
  1690.   last_expr_type = 0;
  1691.   for (n = nesting_stack; n; n = n->all)
  1692.     if (n->exit_label != 0)
  1693.       {
  1694.     expand_goto_internal (0, n->exit_label, 0);
  1695.     return 1;
  1696.       }
  1697.  
  1698.   return 0;
  1699. }
  1700.  
  1701. /* Generate RTL to return from the current function, with no value.
  1702.    (That is, we do not do anything about returning any value.)  */
  1703.  
  1704. void
  1705. expand_null_return ()
  1706. {
  1707.   struct nesting *block = block_stack;
  1708.   rtx last_insn = 0;
  1709.  
  1710.   /* Does any pending block have cleanups?  */
  1711.  
  1712.   while (block && block->data.block.cleanups == 0)
  1713.     block = block->next;
  1714.  
  1715.   /* If yes, use a goto to return, since that runs cleanups.  */
  1716.  
  1717.   expand_null_return_1 (last_insn, block != 0);
  1718. }
  1719.  
  1720. /* Output a return with no value.  If LAST_INSN is nonzero,
  1721.    pretend that the return takes place after LAST_INSN.
  1722.    If USE_GOTO is nonzero then don't use a return instruction;
  1723.    go to the return label instead.  This causes any cleanups
  1724.    of pending blocks to be executed normally.  */
  1725.  
  1726. static void
  1727. expand_null_return_1 (last_insn, use_goto)
  1728.      rtx last_insn;
  1729.      int use_goto;
  1730. {
  1731.   rtx end_label = cleanup_label ? cleanup_label : return_label;
  1732.  
  1733.   clear_pending_stack_adjust ();
  1734.   do_pending_stack_adjust ();
  1735.   last_expr_type = 0;
  1736.  
  1737.   /* PCC-struct return always uses an epilogue.  */
  1738.   if (current_function_returns_pcc_struct || use_goto)
  1739.     {
  1740.       if (end_label == 0)
  1741.     end_label = return_label = gen_label_rtx ();
  1742.       expand_goto_internal (0, end_label, last_insn);
  1743.       return;
  1744.     }
  1745.  
  1746.   /* Otherwise output a simple return-insn if one is available,
  1747.      unless it won't do the job.  */
  1748. #ifdef HAVE_return
  1749.   if (HAVE_return && cleanup_label == 0)
  1750.     {
  1751.       emit_jump_insn (gen_return ());
  1752.       emit_barrier ();
  1753.       return;
  1754.     }
  1755. #endif
  1756.  
  1757.   /* Otherwise jump to the epilogue.  */
  1758.   expand_goto_internal (0, end_label, last_insn);
  1759. }
  1760.  
  1761. /* Generate RTL to evaluate the expression RETVAL and return it
  1762.    from the current function.  */
  1763.  
  1764. void
  1765. expand_return (retval)
  1766.      tree retval;
  1767. {
  1768.   /* If there are any cleanups to be performed, then they will
  1769.      be inserted following LAST_INSN.  It is desirable
  1770.      that the last_insn, for such purposes, should be the
  1771.      last insn before computing the return value.  Otherwise, cleanups
  1772.      which call functions can clobber the return value.  */
  1773.   /* ??? rms: I think that is erroneous, because in C++ it would
  1774.      run destructors on variables that might be used in the subsequent
  1775.      computation of the return value.  */
  1776.   rtx last_insn = 0;
  1777.   register rtx val = 0;
  1778.   register rtx op0;
  1779.   tree retval_rhs;
  1780.   int cleanups;
  1781.   struct nesting *block;
  1782.  
  1783.   /* Are any cleanups needed?  E.g. C++ destructors to be run?  */
  1784.   cleanups = 0;
  1785.   for (block = block_stack; block; block = block->next)
  1786.     if (block->data.block.cleanups != 0)
  1787.       {
  1788.     cleanups = 1;
  1789.     break;
  1790.       }
  1791.  
  1792.   if (TREE_CODE (retval) == RESULT_DECL)
  1793.     retval_rhs = retval;
  1794.   else if ((TREE_CODE (retval) == MODIFY_EXPR || TREE_CODE (retval) == INIT_EXPR)
  1795.        && TREE_CODE (TREE_OPERAND (retval, 0)) == RESULT_DECL)
  1796.     retval_rhs = TREE_OPERAND (retval, 1);
  1797.   else if (TREE_TYPE (retval) == void_type_node)
  1798.     /* Recognize tail-recursive call to void function.  */
  1799.     retval_rhs = retval;
  1800.   else
  1801.     retval_rhs = NULL_TREE;
  1802.  
  1803.   /* Only use `last_insn' if there are cleanups which must be run.  */
  1804.   if (cleanups || cleanup_label != 0)
  1805.     last_insn = get_last_insn ();
  1806.  
  1807.   /* For tail-recursive call to current function,
  1808.      just jump back to the beginning.
  1809.      It's unsafe if any auto variable in this function
  1810.      has its address taken; for simplicity,
  1811.      require stack frame to be empty.  */
  1812.   if (optimize && retval_rhs != 0
  1813.       && frame_offset == STARTING_FRAME_OFFSET
  1814.       && TREE_CODE (retval_rhs) == CALL_EXPR
  1815.       && TREE_CODE (TREE_OPERAND (retval_rhs, 0)) == ADDR_EXPR
  1816.       && TREE_OPERAND (TREE_OPERAND (retval_rhs, 0), 0) == this_function
  1817.       /* Finish checking validity, and if valid emit code
  1818.      to set the argument variables for the new call.  */
  1819.       && tail_recursion_args (TREE_OPERAND (retval_rhs, 1),
  1820.                   DECL_ARGUMENTS (this_function)))
  1821.     {
  1822.       if (tail_recursion_label == 0)
  1823.     {
  1824.       tail_recursion_label = gen_label_rtx ();
  1825.       emit_label_after (tail_recursion_label,
  1826.                 tail_recursion_reentry);
  1827.     }
  1828.       expand_goto_internal (0, tail_recursion_label, last_insn);
  1829.       emit_barrier ();
  1830.       return;
  1831.     }
  1832. #ifdef HAVE_return
  1833.   /* This optimization is safe if there are local cleanups
  1834.      because expand_null_return takes care of them.
  1835.      ??? I think it should also be safe when there is a cleanup label,
  1836.      because expand_null_return takes care of them, too.
  1837.      Any reason why not?  */
  1838.   if (HAVE_return && cleanup_label == 0
  1839.       && ! current_function_returns_pcc_struct)
  1840.     {
  1841.       /* If this is  return x == y;  then generate
  1842.      if (x == y) return 1; else return 0;
  1843.      if we can do it with explicit return insns.  */
  1844.       if (retval_rhs)
  1845.     switch (TREE_CODE (retval_rhs))
  1846.       {
  1847.       case EQ_EXPR:
  1848.       case NE_EXPR:
  1849.       case GT_EXPR:
  1850.       case GE_EXPR:
  1851.       case LT_EXPR:
  1852.       case LE_EXPR:
  1853.       case TRUTH_ANDIF_EXPR:
  1854.       case TRUTH_ORIF_EXPR:
  1855.       case TRUTH_AND_EXPR:
  1856.       case TRUTH_OR_EXPR:
  1857.       case TRUTH_NOT_EXPR:
  1858.         op0 = gen_label_rtx ();
  1859.         val = DECL_RTL (DECL_RESULT (this_function));
  1860.         jumpifnot (retval_rhs, op0);
  1861.         emit_move_insn (val, const1_rtx);
  1862.         emit_insn (gen_rtx (USE, VOIDmode, val));
  1863.         expand_null_return ();
  1864.         emit_label (op0);
  1865.         emit_move_insn (val, const0_rtx);
  1866.         emit_insn (gen_rtx (USE, VOIDmode, val));
  1867.         expand_null_return ();
  1868.         return;
  1869.       }
  1870.     }
  1871. #endif /* HAVE_return */
  1872.  
  1873.   if (cleanups
  1874.       && retval_rhs != 0
  1875.       && TREE_TYPE (retval_rhs) != void_type_node
  1876.       && GET_CODE (DECL_RTL (DECL_RESULT (this_function))) == REG)
  1877.     {
  1878.       rtx last_insn;
  1879.       /* Calculate the return value into a pseudo reg.  */
  1880.       val = expand_expr (retval_rhs, 0, VOIDmode, 0);
  1881.       emit_queue ();
  1882.       /* Put the cleanups here.  */
  1883.       last_insn = get_last_insn ();
  1884.       /* Copy the value into hard return reg.  */
  1885.       emit_move_insn (DECL_RTL (DECL_RESULT (this_function)), val);
  1886.       val = DECL_RTL (DECL_RESULT (this_function));
  1887.  
  1888.       if (GET_CODE (val) == REG)
  1889.     emit_insn (gen_rtx (USE, VOIDmode, val));
  1890.       expand_null_return_1 (last_insn, cleanups);
  1891.     }
  1892.   else
  1893.     {
  1894.       /* No cleanups or no hard reg used;
  1895.      calculate value into hard return reg
  1896.      and let cleanups come after.  */
  1897.       val = expand_expr (retval, 0, VOIDmode, 0);
  1898.       emit_queue ();
  1899.  
  1900.       val = DECL_RTL (DECL_RESULT (this_function));
  1901.       if (val && GET_CODE (val) == REG)
  1902.     emit_insn (gen_rtx (USE, VOIDmode, val));
  1903.       expand_null_return ();
  1904.     }
  1905. }
  1906.  
  1907. /* Return 1 if the end of the generated RTX is not a barrier.
  1908.    This means code already compiled can drop through.  */
  1909.  
  1910. int
  1911. drop_through_at_end_p ()
  1912. {
  1913.   rtx insn = get_last_insn ();
  1914.   while (insn && GET_CODE (insn) == NOTE)
  1915.     insn = PREV_INSN (insn);
  1916.   return insn && GET_CODE (insn) != BARRIER;
  1917. }
  1918.  
  1919. /* Emit code to alter this function's formal parms for a tail-recursive call.
  1920.    ACTUALS is a list of actual parameter expressions (chain of TREE_LISTs).
  1921.    FORMALS is the chain of decls of formals.
  1922.    Return 1 if this can be done;
  1923.    otherwise return 0 and do not emit any code.  */
  1924.  
  1925. static int
  1926. tail_recursion_args (actuals, formals)
  1927.      tree actuals, formals;
  1928. {
  1929.   register tree a = actuals, f = formals;
  1930.   register int i;
  1931.   register rtx *argvec;
  1932.  
  1933.   /* Check that number and types of actuals are compatible
  1934.      with the formals.  This is not always true in valid C code.
  1935.      Also check that no formal needs to be addressable
  1936.      and that all formals are scalars.  */
  1937.  
  1938.   /* Also count the args.  */
  1939.  
  1940.   for (a = actuals, f = formals, i = 0; a && f; a = TREE_CHAIN (a), f = TREE_CHAIN (f), i++)
  1941.     {
  1942.       if (TREE_TYPE (TREE_VALUE (a)) != TREE_TYPE (f))
  1943.     return 0;
  1944.       if (GET_CODE (DECL_RTL (f)) != REG || DECL_MODE (f) == BLKmode)
  1945.     return 0;
  1946.     }
  1947.   if (a != 0 || f != 0)
  1948.     return 0;
  1949.  
  1950.   /* Compute all the actuals.  */
  1951.  
  1952.   argvec = (rtx *) alloca (i * sizeof (rtx));
  1953.  
  1954.   for (a = actuals, i = 0; a; a = TREE_CHAIN (a), i++)
  1955.     argvec[i] = expand_expr (TREE_VALUE (a), 0, VOIDmode, 0);
  1956.  
  1957.   /* Find which actual values refer to current values of previous formals.
  1958.      Copy each of them now, before any formal is changed.  */
  1959.  
  1960.   for (a = actuals, i = 0; a; a = TREE_CHAIN (a), i++)
  1961.     {
  1962.       int copy = 0;
  1963.       register int j;
  1964.       for (f = formals, j = 0; j < i; f = TREE_CHAIN (f), j++)
  1965.     if (reg_mentioned_p (DECL_RTL (f), argvec[i]))
  1966.       { copy = 1; break; }
  1967.       if (copy)
  1968.     argvec[i] = copy_to_reg (argvec[i]);
  1969.     }
  1970.  
  1971.   /* Store the values of the actuals into the formals.  */
  1972.  
  1973.   for (f = formals, a = actuals, i = 0; f;
  1974.        f = TREE_CHAIN (f), a = TREE_CHAIN (a), i++)
  1975.     {
  1976.       if (DECL_MODE (f) == GET_MODE (argvec[i]))
  1977.     emit_move_insn (DECL_RTL (f), argvec[i]);
  1978.       else
  1979.     convert_move (DECL_RTL (f), argvec[i],
  1980.               TREE_UNSIGNED (TREE_TYPE (TREE_VALUE (a))));
  1981.     }
  1982.  
  1983.   return 1;
  1984. }
  1985.  
  1986. /* Generate the RTL code for entering a binding contour.
  1987.    The variables are declared one by one, by calls to `expand_decl'.
  1988.  
  1989.    EXIT_FLAG is nonzero if this construct should be visible to
  1990.    `exit_something'.  */
  1991.  
  1992. void
  1993. expand_start_bindings (exit_flag)
  1994.      int exit_flag;
  1995. {
  1996.   struct nesting *thisblock
  1997.     = (struct nesting *) obstack_alloc (&stmt_obstack, sizeof (struct nesting));
  1998.  
  1999.   rtx note = emit_note (0, NOTE_INSN_BLOCK_BEG);
  2000.  
  2001.   /* Make an entry on block_stack for the block we are entering.  */
  2002.  
  2003.   thisblock->next = block_stack;
  2004.   thisblock->all = nesting_stack;
  2005.   thisblock->depth = ++nesting_depth;
  2006.   thisblock->data.block.stack_level = 0;
  2007.   thisblock->data.block.cleanups = 0;
  2008.   /* We build this even if the cleanups lists are empty
  2009.      because we rely on having an element in the chain
  2010.      for each block that is pending.  */
  2011.   if (block_stack)
  2012.     {
  2013.       if (block_stack->data.block.cleanups == NULL_TREE
  2014.       && (block_stack->data.block.outer_cleanups == NULL_TREE
  2015.           || block_stack->data.block.outer_cleanups == empty_cleanup_list))
  2016.     thisblock->data.block.outer_cleanups = empty_cleanup_list;
  2017.       else
  2018.     thisblock->data.block.outer_cleanups
  2019.       = tree_cons (NULL_TREE, block_stack->data.block.cleanups,
  2020.                block_stack->data.block.outer_cleanups);
  2021.     }
  2022.   else
  2023.     thisblock->data.block.outer_cleanups = 0;
  2024.   thisblock->data.block.label_chain = 0;
  2025.   thisblock->data.block.innermost_stack_block = stack_block_stack;
  2026.   thisblock->data.block.first_insn = note;
  2027.   thisblock->exit_label = exit_flag ? gen_label_rtx () : 0;
  2028.   block_stack = thisblock;
  2029.   nesting_stack = thisblock;
  2030. }
  2031.  
  2032. /* Output a USE for any register use in RTL.
  2033.    This is used with -noreg to mark the extent of lifespan
  2034.    of any registers used in a user-visible variable's DECL_RTL.  */
  2035.  
  2036. void
  2037. use_variable (rtl)
  2038.      rtx rtl;
  2039. {
  2040.   if (GET_CODE (rtl) == REG)
  2041.     /* This is a register variable.  */
  2042.     emit_insn (gen_rtx (USE, VOIDmode, rtl));
  2043.   else if (GET_CODE (rtl) == MEM
  2044.        && GET_CODE (XEXP (rtl, 0)) == REG
  2045.        && XEXP (rtl, 0) != frame_pointer_rtx
  2046.        && XEXP (rtl, 0) != arg_pointer_rtx)
  2047.     /* This is a variable-sized structure.  */
  2048.     emit_insn (gen_rtx (USE, VOIDmode, XEXP (rtl, 0)));
  2049. }
  2050.  
  2051. /* Like use_variable except that it outputs the USEs after INSN
  2052.    instead of at the end of the insn-chain.  */
  2053.  
  2054. static void
  2055. use_variable_after (rtl, insn)
  2056.      rtx rtl, insn;
  2057. {
  2058.   if (GET_CODE (rtl) == REG)
  2059.     /* This is a register variable.  */
  2060.     emit_insn_after (gen_rtx (USE, VOIDmode, rtl), insn);
  2061.   else if (GET_CODE (rtl) == MEM
  2062.        && GET_CODE (XEXP (rtl, 0)) == REG
  2063.        && XEXP (rtl, 0) != frame_pointer_rtx
  2064.        && XEXP (rtl, 0) != arg_pointer_rtx)
  2065.     /* This is a variable-sized structure.  */
  2066.     emit_insn_after (gen_rtx (USE, VOIDmode, XEXP (rtl, 0)), insn);
  2067. }
  2068.  
  2069. /* Generate RTL code to terminate a binding contour.
  2070.    VARS is the chain of VAR_DECL nodes
  2071.    for the variables bound in this contour.
  2072.    MARK_ENDS is nonzero if we should put a note at the beginning
  2073.    and end of this binding contour.
  2074.  
  2075.    DONT_JUMP_IN is nonzero if it is not valid to jump into this contour.
  2076.    (That is true automatically if the contour has a saved stack level.)  */
  2077.  
  2078. void
  2079. expand_end_bindings (vars, mark_ends, dont_jump_in)
  2080.      tree vars;
  2081.      int mark_ends;
  2082.      int dont_jump_in;
  2083. {
  2084.   register struct nesting *thisblock = block_stack;
  2085.   register tree decl;
  2086.  
  2087.   if (warn_unused)
  2088.     for (decl = vars; decl; decl = TREE_CHAIN (decl))
  2089.       if (! TREE_USED (decl) && TREE_CODE (decl) == VAR_DECL)
  2090.     warning_with_decl (decl, "unused variable `%s'");
  2091.  
  2092.   /* Mark the beginning and end of the scope if requested.  */
  2093.  
  2094.   if (mark_ends)
  2095.     emit_note (0, NOTE_INSN_BLOCK_END);
  2096.   else
  2097.     /* Get rid of the beginning-mark if we don't make an end-mark.  */
  2098.     NOTE_LINE_NUMBER (thisblock->data.block.first_insn) = NOTE_INSN_DELETED;
  2099.  
  2100.   if (thisblock->exit_label)
  2101.     {
  2102.       do_pending_stack_adjust ();
  2103.       emit_label (thisblock->exit_label);
  2104.     }
  2105.  
  2106.   if (dont_jump_in
  2107.       || thisblock->data.block.stack_level != 0
  2108.       || thisblock->data.block.cleanups != 0)
  2109.     {
  2110.       struct label_chain *chain;
  2111.  
  2112.       /* Any labels in this block are no longer valid to go to.
  2113.      Mark them to cause an error message.  */
  2114.       for (chain = thisblock->data.block.label_chain; chain; chain = chain->next)
  2115.     {
  2116.       TREE_PACKED (chain->label) = 1;
  2117.       /* If any goto without a fixup came to this label,
  2118.          that must be an error, because gotos without fixups
  2119.          come from outside all saved stack-levels and all cleanups.  */
  2120.       if (TREE_ADDRESSABLE (chain->label))
  2121.         error_with_decl (chain->label,
  2122.                  "label `%s' used before containing binding contour");
  2123.     }
  2124.     }
  2125.  
  2126.   /* Restore stack level in effect before the block
  2127.      (only if variable-size objects allocated).  */
  2128.  
  2129.   if (thisblock->data.block.stack_level != 0
  2130.       || thisblock->data.block.cleanups != 0)
  2131.     {
  2132.       /* Perform any cleanups associated with the block.  */
  2133.       int old_expr_stmts_for_value = expr_stmts_for_value;
  2134.       rtx old_last_expr_value = last_expr_value;
  2135.       tree old_last_expr_type = last_expr_type;
  2136.  
  2137.       /* Don't let cleanups affect ({...}) constructs.  */
  2138.       expr_stmts_for_value = 0;
  2139.       expand_cleanups (thisblock->data.block.cleanups, 0);
  2140.       do_pending_stack_adjust ();
  2141.       expr_stmts_for_value = old_expr_stmts_for_value;
  2142.       last_expr_value = old_last_expr_value;
  2143.       last_expr_type = old_last_expr_type;
  2144.  
  2145.       /* Restore the stack level.  */
  2146.  
  2147.       if (thisblock->data.block.stack_level != 0)
  2148.     emit_move_insn (stack_pointer_rtx,
  2149.             thisblock->data.block.stack_level);
  2150.  
  2151.       /* Any gotos out of this block must also do these things.
  2152.      Also report any gotos with fixups that came to labels in this level.  */
  2153.       fixup_gotos (thisblock,
  2154.            thisblock->data.block.stack_level,
  2155.            thisblock->data.block.cleanups,
  2156.            thisblock->data.block.first_insn,
  2157.            dont_jump_in);
  2158.     }
  2159.  
  2160.   /* If doing stupid register allocation, make sure lives of all
  2161.      register variables declared here extend thru end of scope.  */
  2162.  
  2163.   if (obey_regdecls)
  2164.     for (decl = vars; decl; decl = TREE_CHAIN (decl))
  2165.       {
  2166.     rtx rtl = DECL_RTL (decl);
  2167.     if (TREE_CODE (decl) == VAR_DECL && rtl != 0)
  2168.       use_variable (rtl);
  2169.       }
  2170.  
  2171.   /* Restore block_stack level for containing block.  */
  2172.  
  2173.   stack_block_stack = thisblock->data.block.innermost_stack_block;
  2174.   POPSTACK (block_stack);
  2175. }
  2176.  
  2177. /* Generate RTL for the automatic variable declaration DECL.
  2178.    (Other kinds of declarations are simply ignored if seen here.)
  2179.    There is no special support here for C++ constructors.
  2180.    They should be handled by the proper code in DECL_INITIAL.  */
  2181.  
  2182. void
  2183. expand_decl (decl)
  2184.      register tree decl;
  2185. {
  2186.   struct nesting *thisblock = block_stack;
  2187.   tree type = TREE_TYPE (decl);
  2188.  
  2189.   /* Only automatic variables need any expansion done.
  2190.      Static and external variables, and external functions,
  2191.      will be handled by `assemble_variable' (called from finish_decl).
  2192.      TYPE_DECL and CONST_DECL require nothing.
  2193.      PARM_DECLs are handled in `assign_parms'.  */
  2194.  
  2195.   if (TREE_CODE (decl) != VAR_DECL)
  2196.     return;
  2197.   if (TREE_STATIC (decl) || TREE_EXTERNAL (decl))
  2198.     return;
  2199.  
  2200.   /* Create the RTL representation for the variable.  */
  2201.  
  2202.   if (type == error_mark_node)
  2203.     DECL_RTL (decl) = gen_rtx (MEM, BLKmode, const0_rtx);
  2204.   else if (DECL_SIZE (decl) == 0)
  2205.     /* Variable with incomplete type.  */
  2206.     {
  2207.       if (DECL_INITIAL (decl) == 0)
  2208.     /* Error message was already done; now avoid a crash.  */
  2209.     DECL_RTL (decl) = assign_stack_local (DECL_MODE (decl), 0);
  2210.       else
  2211.     /* An initializer is going to decide the size of this array.
  2212.        Until we know the size, represent its address with a reg.  */
  2213.     DECL_RTL (decl) = gen_rtx (MEM, BLKmode, gen_reg_rtx (Pmode));
  2214.     }
  2215.   else if (DECL_MODE (decl) != BLKmode
  2216.        /* If -ffloat-store, don't put explicit float vars
  2217.           into regs.  */
  2218.        && !(flag_float_store
  2219.         && TREE_CODE (type) == REAL_TYPE)
  2220.        && ! TREE_VOLATILE (decl)
  2221.        && ! TREE_ADDRESSABLE (decl)
  2222.        && (TREE_REGDECL (decl) || ! obey_regdecls))
  2223.     {
  2224.       /* Automatic variable that can go in a register.  */
  2225.       DECL_RTL (decl) = gen_reg_rtx (DECL_MODE (decl));
  2226.       if (TREE_CODE (type) == POINTER_TYPE)
  2227.     mark_reg_pointer (DECL_RTL (decl));
  2228.       REG_USERVAR_P (DECL_RTL (decl)) = 1;
  2229.     }
  2230.   else if (TREE_LITERAL (DECL_SIZE (decl)))
  2231.     {
  2232.       rtx oldaddr = 0;
  2233.       rtx addr;
  2234.  
  2235.       /* If we previously made RTL for this decl, it must be an array
  2236.      whose size was determined by the initializer.
  2237.      The old address was a register; set that register now
  2238.      to the proper address.  */
  2239.       if (DECL_RTL (decl) != 0)
  2240.     {
  2241.       if (GET_CODE (DECL_RTL (decl)) != MEM
  2242.           || GET_CODE (XEXP (DECL_RTL (decl), 0)) != REG)
  2243.         abort ();
  2244.       oldaddr = XEXP (DECL_RTL (decl), 0);
  2245.     }
  2246.  
  2247.       /* Variable of fixed size that goes on the stack.  */
  2248.       DECL_RTL (decl)
  2249.     = assign_stack_local (DECL_MODE (decl),
  2250.                   (TREE_INT_CST_LOW (DECL_SIZE (decl))
  2251.                    * DECL_SIZE_UNIT (decl)
  2252.                    + BITS_PER_UNIT - 1)
  2253.                   / BITS_PER_UNIT);
  2254.       if (oldaddr)
  2255.     {
  2256.       addr = force_operand (XEXP (DECL_RTL (decl), 0), oldaddr);
  2257.       emit_move_insn (oldaddr, addr);
  2258.     }
  2259.  
  2260.       /* If this is a memory ref that contains aggregate components,
  2261.      mark it as such for cse and loop optimize.  */
  2262.       MEM_IN_STRUCT_P (DECL_RTL (decl))
  2263.     = (TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE
  2264.        || TREE_CODE (TREE_TYPE (decl)) == RECORD_TYPE
  2265.        || TREE_CODE (TREE_TYPE (decl)) == UNION_TYPE);
  2266. #if 0
  2267.       /* If this is in memory because of -ffloat-store,
  2268.      set the volatile bit, to prevent optimizations from
  2269.      undoing the effects.  */
  2270.       if (flag_float_store && TREE_CODE (type) == REAL_TYPE)
  2271.     MEM_VOLATILE_P (DECL_RTL (decl)) = 1;
  2272. #endif
  2273.     }
  2274.   else
  2275.     /* Dynamic-size object: must push space on the stack.  */
  2276.     {
  2277.       rtx address, size;
  2278.  
  2279.       frame_pointer_needed = 1;
  2280.  
  2281.       /* Record the stack pointer on entry to block, if have
  2282.      not already done so.  */
  2283.       if (thisblock->data.block.stack_level == 0)
  2284.     {
  2285.       do_pending_stack_adjust ();
  2286.       thisblock->data.block.stack_level
  2287.         = copy_to_reg (stack_pointer_rtx);
  2288.       stack_block_stack = thisblock;
  2289.     }
  2290.  
  2291.       /* Compute the variable's size, in bytes.  */
  2292.       size = expand_expr (convert_units (DECL_SIZE (decl),
  2293.                      DECL_SIZE_UNIT (decl),
  2294.                      BITS_PER_UNIT),
  2295.               0, VOIDmode, 0);
  2296.  
  2297.       /* Round it up to this machine's required stack boundary.  */
  2298. #ifdef STACK_BOUNDARY
  2299.       /* Avoid extra code if we can prove it's a multiple already.  */
  2300.       if (DECL_SIZE_UNIT (decl) % STACK_BOUNDARY)
  2301.     {
  2302. #ifdef STACK_POINTER_OFFSET
  2303.       /* Avoid extra code if we can prove that adding STACK_POINTER_OFFSET
  2304.          will not give this address invalid alignment.  */
  2305.       if (DECL_ALIGN (decl) > ((STACK_POINTER_OFFSET * BITS_PER_UNIT) % STACK_BOUNDARY))
  2306.         size = plus_constant (size,
  2307.                   STACK_POINTER_OFFSET % (STACK_BOUNDARY / BITS_PER_UNIT));
  2308. #endif
  2309.       size = round_push (size);
  2310.     }
  2311. #endif /* STACK_BOUNDARY */
  2312.  
  2313.       /* Make space on the stack, and get an rtx for the address of it.  */
  2314. #ifdef STACK_GROWS_DOWNWARD
  2315.       anti_adjust_stack (size);
  2316. #endif
  2317.       address = copy_to_reg (stack_pointer_rtx);
  2318. #ifdef STACK_POINTER_OFFSET
  2319.       {
  2320.     /* If the contents of the stack pointer reg are offset from the
  2321.        actual top-of-stack address, add the offset here.  */
  2322.     rtx sp_offset = gen_rtx (CONST_INT, VOIDmode, STACK_POINTER_OFFSET);
  2323. #ifdef STACK_BOUNDARY
  2324. #ifdef STACK_GROWS_DOWNWARD
  2325.     int direction = 1;
  2326. #else /* not STACK_GROWS_DOWNWARD */
  2327.     int direction = 0;
  2328. #endif /* not STACK_GROWS_DOWNWARD */
  2329.     if (DECL_ALIGN (decl) > ((STACK_POINTER_OFFSET * BITS_PER_UNIT) % STACK_BOUNDARY))
  2330.       sp_offset = plus_constant (sp_offset,
  2331.                      (STACK_POINTER_OFFSET
  2332.                       % (STACK_BOUNDARY / BITS_PER_UNIT)
  2333.                       * direction));
  2334. #endif /* STACK_BOUNDARY */
  2335.     emit_insn (gen_add2_insn (address, sp_offset));
  2336.       }
  2337. #endif /* STACK_POINTER_OFFSET */
  2338. #ifndef STACK_GROWS_DOWNWARD
  2339.       anti_adjust_stack (size);
  2340. #endif
  2341.  
  2342.       /* Some systems require a particular insn to refer to the stack
  2343.      to make the pages exist.  */
  2344. #ifdef HAVE_probe
  2345.       if (HAVE_probe)
  2346.     emit_insn (gen_probe ());
  2347. #endif
  2348.  
  2349.       /* Reference the variable indirect through that rtx.  */
  2350.       DECL_RTL (decl) = gen_rtx (MEM, DECL_MODE (decl), address);
  2351.     }
  2352.  
  2353.   if (TREE_VOLATILE (decl))
  2354.     MEM_VOLATILE_P (DECL_RTL (decl)) = 1;
  2355.   if (TREE_READONLY (decl))
  2356.     RTX_UNCHANGING_P (DECL_RTL (decl)) = 1;
  2357.  
  2358.   /* If doing stupid register allocation, make sure life of any
  2359.      register variable starts here, at the start of its scope.  */
  2360.  
  2361.   if (obey_regdecls)
  2362.     use_variable (DECL_RTL (decl));
  2363. }
  2364.  
  2365. /* Emit code to perform the initialization of a declaration DECL.  */
  2366.  
  2367. void
  2368. expand_decl_init (decl)
  2369.      tree decl;
  2370. {
  2371.   if (TREE_STATIC (decl))
  2372.     return;
  2373.  
  2374.   /* Compute and store the initial value now.  */
  2375.  
  2376.   if (DECL_INITIAL (decl) == error_mark_node)
  2377.     {
  2378.       enum tree_code code = TREE_CODE (TREE_TYPE (decl));
  2379.       if (code == INTEGER_TYPE || code == REAL_TYPE || code == ENUMERAL_TYPE
  2380.       || code == POINTER_TYPE)
  2381.     expand_assignment (decl, convert (TREE_TYPE (decl), integer_zero_node),
  2382.                0, 0);
  2383.       emit_queue ();
  2384.     }
  2385.   else if (DECL_INITIAL (decl) && TREE_CODE (DECL_INITIAL (decl)) != TREE_LIST)
  2386.     {
  2387.       emit_line_note (DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
  2388.       expand_assignment (decl, DECL_INITIAL (decl), 0, 0);
  2389.       emit_queue ();
  2390.     }
  2391. }
  2392.  
  2393. /* CLEANUP is an expression to be executed at exit from this binding contour;
  2394.    for example, in C++, it might call the destructor for this variable.
  2395.  
  2396.    If CLEANUP contains any SAVE_EXPRs, then you must preevaluate them
  2397.    either before or after calling `expand_decl' but before compiling
  2398.    any subsequent expressions.  This is because CLEANUP may be expanded
  2399.    more than once, on different branches of execution.
  2400.    For the same reason, CLEANUP may not contain a CALL_EXPR
  2401.    except as its topmost node--else `preexpand_calls' would get confused.
  2402.  
  2403.    If CLEANUP is nonzero and DECL is zero, we record a cleanup
  2404.    that is not associated with any particular variable.
  2405.  
  2406.    Return 0 if such an expansion is invalid.  Otherwise, return 1.  */
  2407. int
  2408. expand_decl_cleanup (decl, cleanup)
  2409. {
  2410.   struct nesting *thisblock = block_stack;
  2411.  
  2412.   /* Record the cleanup if there is one.  */
  2413.  
  2414.   if (cleanup != 0)
  2415.     {
  2416.       if (thisblock == 0)
  2417.     return 0;
  2418.  
  2419.       thisblock->data.block.cleanups
  2420.     = temp_tree_cons (decl, cleanup, thisblock->data.block.cleanups);
  2421.       /* If this block has a cleanup, it belongs in stack_block_stack.  */
  2422.       stack_block_stack = thisblock;
  2423.     }
  2424.   return 1;
  2425. }
  2426.  
  2427. /* DECL is an anonymous union.  CLEANUP is a cleanup for DECL.
  2428.    DECL_ELTS is the list of elements that belong to DECL's type.
  2429.    In each, the TREE_VALUE is a VAR_DECL, and the TREE_PURPOSE a cleanup.  */
  2430.  
  2431. void
  2432. expand_anon_union_decl (decl, cleanup, decl_elts)
  2433.      tree decl, cleanup, decl_elts;
  2434. {
  2435.   struct nesting *thisblock = block_stack;
  2436.   rtx x;
  2437.  
  2438.   expand_decl (decl, cleanup);
  2439.   x = DECL_RTL (decl);
  2440.  
  2441.   while (decl_elts)
  2442.     {
  2443.       tree decl_elt = TREE_VALUE (decl_elts);
  2444.       tree cleanup_elt = TREE_PURPOSE (decl_elts);
  2445.       enum machine_mode tmode = TYPE_MODE (TREE_TYPE (decl_elt));
  2446.  
  2447.       if (GET_CODE (x) == MEM)
  2448.     {
  2449.       /* @@ calling `change_address' means that we cannot
  2450.          be at top-level, since `memory_address' might try
  2451.          to kick this address into a register, which won't
  2452.          work.  Will this work?  */
  2453.       rtx new = gen_rtx (MEM, tmode, XEXP (x, 0));
  2454.       DECL_RTL (decl_elt) = new;
  2455.       MEM_VOLATILE_P (new) = MEM_VOLATILE_P (x);
  2456.       RTX_UNCHANGING_P (new) = RTX_UNCHANGING_P (x);
  2457.       MEM_IN_STRUCT_P (new) = MEM_IN_STRUCT_P (x);
  2458.     }
  2459.       else
  2460.     DECL_RTL (decl_elt) = gen_rtx (SUBREG, tmode, x, 0);
  2461.  
  2462.       /* Record the cleanup if there is one.  */
  2463.  
  2464.       if (cleanup != 0)
  2465.     thisblock->data.block.cleanups
  2466.       = temp_tree_cons (decl_elt, cleanup_elt,
  2467.                 thisblock->data.block.cleanups);
  2468.  
  2469.       decl_elts = TREE_CHAIN (decl_elts);
  2470.     }
  2471. }
  2472.  
  2473. /* Expand a list of cleanups LIST.
  2474.    Elements may be expressions or may be nested lists.
  2475.  
  2476.    If DONT_DO is nonnull, then any list-element
  2477.    whose TREE_PURPOSE matches DONT_DO is omitted.
  2478.    This is sometimes used to avoid a cleanup associated with
  2479.    a value that is being returned out of the scope.  */
  2480.  
  2481. static void
  2482. expand_cleanups (list, dont_do)
  2483.      tree list;
  2484.      tree dont_do;
  2485. {
  2486.   tree tail;
  2487.   for (tail = list; tail; tail = TREE_CHAIN (tail))
  2488.     if (dont_do == 0 || TREE_PURPOSE (tail) != dont_do)
  2489.       {
  2490.     if (TREE_CODE (TREE_VALUE (tail)) == TREE_LIST)
  2491.       expand_cleanups (TREE_VALUE (tail), dont_do);
  2492.     else
  2493.       expand_expr (TREE_VALUE (tail), const0_rtx, VOIDmode, 0);
  2494.       }
  2495. }
  2496.  
  2497. /* Expand a list of cleanups for a goto fixup.
  2498.    The expansion is put into the insn chain after the insn *BEFORE_JUMP
  2499.    and *BEFORE_JUMP is set to the insn that now comes before the jump.  */
  2500.  
  2501. static void
  2502. fixup_cleanups (list, before_jump)
  2503.      tree list;
  2504.      rtx *before_jump;
  2505. {
  2506.   rtx beyond_jump = get_last_insn ();
  2507.   rtx new_before_jump;
  2508.  
  2509.   expand_cleanups (list, 0);
  2510.   do_pending_stack_adjust ();
  2511.  
  2512.   new_before_jump = get_last_insn ();
  2513.  
  2514.   if (beyond_jump != new_before_jump)
  2515.     /* If cleanups expand to nothing, don't reorder.  */
  2516.     reorder_insns (NEXT_INSN (beyond_jump), new_before_jump, *before_jump);
  2517.  
  2518.   *before_jump = new_before_jump;
  2519. }
  2520.  
  2521. /* Move all cleanups from the current block_stack
  2522.    to the containing block_stack, where they are assumed to
  2523.    have been created.  If anything can cause a temporary to
  2524.    be created, but not expanded for more than one level of
  2525.    block_stacks, then this code will have to change.  */
  2526.  
  2527. void
  2528. move_cleanups_up ()
  2529. {
  2530.   struct nesting *block = block_stack;
  2531.   struct nesting *outer = block->next;
  2532.  
  2533.   outer->data.block.cleanups
  2534.     = chainon (block->data.block.cleanups,
  2535.            outer->data.block.cleanups);
  2536.   block->data.block.cleanups = 0;
  2537. }
  2538.  
  2539. int
  2540. this_contour_has_cleanups_p ()
  2541. {
  2542.   return block_stack && block_stack->data.block.cleanups != 0;
  2543. }
  2544.  
  2545. /* Enter a case (Pascal) or switch (C) statement.
  2546.    Push a block onto case_stack and nesting_stack
  2547.    to accumulate the case-labels that are seen
  2548.    and to record the labels generated for the statement.
  2549.  
  2550.    EXIT_FLAG is nonzero if `exit_something' should exit this case stmt.
  2551.    Otherwise, this construct is transparent for `exit_something'.
  2552.  
  2553.    EXPR is the index-expression to be dispatched on.
  2554.    TYPE is its nominal type.  We could simply convert EXPR to this type,
  2555.    but instead we take short cuts.  */
  2556.  
  2557. void
  2558. expand_start_case (exit_flag, expr, type)
  2559.      int exit_flag;
  2560.      tree expr;
  2561.      tree type;
  2562. {
  2563.   register struct nesting *thiscase
  2564.     = (struct nesting *) obstack_alloc (&stmt_obstack, sizeof (struct nesting));
  2565.  
  2566.   /* Make an entry on case_stack for the case we are entering.  */
  2567.  
  2568.   thiscase->next = case_stack;
  2569.   thiscase->all = nesting_stack;
  2570.   thiscase->depth = ++nesting_depth;
  2571.   thiscase->exit_label = exit_flag ? gen_label_rtx () : 0;
  2572.   thiscase->data.case_stmt.case_list = 0;
  2573.   thiscase->data.case_stmt.index_expr = expr;
  2574.   thiscase->data.case_stmt.nominal_type = type;
  2575.   thiscase->data.case_stmt.default_label = 0;
  2576.   thiscase->data.case_stmt.num_ranges = 0;
  2577.   case_stack = thiscase;
  2578.   nesting_stack = thiscase;
  2579.  
  2580.   do_pending_stack_adjust ();
  2581.  
  2582.   /* Make sure case_stmt.start points to something that won't
  2583.      need any transformation before expand_end_case.  */
  2584.   emit_note (0, NOTE_INSN_DELETED);
  2585.  
  2586.   thiscase->data.case_stmt.start = get_last_insn ();
  2587. }
  2588.  
  2589. /* Start a "dummy case statement" within which case labels are invalid
  2590.    and are not connected to any larger real case statement.
  2591.    This can be used if you don't want to let a case statement jump
  2592.    into the middle of certain kinds of constructs.  */
  2593.  
  2594. void
  2595. expand_start_case_dummy ()
  2596. {
  2597.   register struct nesting *thiscase
  2598.     = (struct nesting *) obstack_alloc (&stmt_obstack, sizeof (struct nesting));
  2599.  
  2600.   /* Make an entry on case_stack for the dummy.  */
  2601.  
  2602.   thiscase->next = case_stack;
  2603.   thiscase->all = nesting_stack;
  2604.   thiscase->depth = ++nesting_depth;
  2605.   thiscase->exit_label = 0;
  2606.   thiscase->data.case_stmt.case_list = 0;
  2607.   thiscase->data.case_stmt.start = 0;
  2608.   thiscase->data.case_stmt.nominal_type = 0;
  2609.   thiscase->data.case_stmt.default_label = 0;
  2610.   thiscase->data.case_stmt.num_ranges = 0;
  2611.   case_stack = thiscase;
  2612.   nesting_stack = thiscase;
  2613. }
  2614.  
  2615. /* End a dummy case statement.  */
  2616.  
  2617. void
  2618. expand_end_case_dummy ()
  2619. {
  2620.   POPSTACK (case_stack);
  2621. }
  2622.  
  2623. /* Accumulate one case or default label inside a case or switch statement.
  2624.    VALUE is the value of the case (a null pointer, for a default label).
  2625.  
  2626.    If not currently inside a case or switch statement, return 1 and do
  2627.    nothing.  The caller will print a language-specific error message.
  2628.    If VALUE is a duplicate or overlaps, return 2 and do nothing.
  2629.    If VALUE is out of range, return 3 and do nothing.
  2630.    Return 0 on success.
  2631.  
  2632.    Extended to handle range statements, should they ever
  2633.    be adopted.  */
  2634.  
  2635. int
  2636. pushcase (value, label)
  2637.      register tree value;
  2638.      register tree label;
  2639. {
  2640.   register struct case_node **l;
  2641.   register struct case_node *n;
  2642.   tree index_type;
  2643.   tree nominal_type;
  2644.  
  2645.   /* Fail if not inside a real case statement.  */
  2646.   if (! (case_stack && case_stack->data.case_stmt.start))
  2647.     return 1;
  2648.  
  2649.   index_type = TREE_TYPE (case_stack->data.case_stmt.index_expr);
  2650.   nominal_type = case_stack->data.case_stmt.nominal_type;
  2651.  
  2652.   /* If the index is erroneous, avoid more problems: pretend to succeed.  */
  2653.   if (index_type == error_mark_node)
  2654.     return 0;
  2655.  
  2656.   /* Convert VALUE to the type in which the comparisons are nominally done.  */
  2657.   if (value != 0)
  2658.     value = convert (nominal_type, value);
  2659.  
  2660.   /* Fail if this value is out of range for the actual type of the index
  2661.      (which may be narrower than NOMINAL_TYPE).  */
  2662.   if (value != 0 && ! int_fits_type_p (value, index_type))
  2663.     return 3;
  2664.  
  2665.   /* Fail if this is a duplicate or overlaps another entry.  */
  2666.   if (value == 0)
  2667.     {
  2668.       if (case_stack->data.case_stmt.default_label != 0)
  2669.     return 2;
  2670.       case_stack->data.case_stmt.default_label = label;
  2671.     }
  2672.   else
  2673.     {
  2674.       /* Find the elt in the chain before which to insert the new value,
  2675.      to keep the chain sorted in increasing order.
  2676.      But report an error if this element is a duplicate.  */
  2677.       for (l = &case_stack->data.case_stmt.case_list;
  2678.        /* Keep going past elements distinctly less than VALUE.  */
  2679.        *l != 0 && tree_int_cst_lt ((*l)->high, value);
  2680.        l = &(*l)->right)
  2681.     ;
  2682.       if (*l)
  2683.     {
  2684.       /* Element we will insert before must be distinctly greater;
  2685.          overlap means error.  */
  2686.       if (! tree_int_cst_lt (value, (*l)->low))
  2687.         return 2;
  2688.     }
  2689.  
  2690.       /* Add this label to the chain, and succeed.
  2691.      Copy VALUE so it is on temporary rather than momentary
  2692.      obstack and will thus survive till the end of the case statement.  */
  2693.       n = (struct case_node *) oballoc (sizeof (struct case_node));
  2694.       n->left = 0;
  2695.       n->right = *l;
  2696.       n->high = n->low = copy_node (value);
  2697.       n->code_label = label;
  2698.       n->test_label = 0;
  2699.       *l = n;
  2700.     }
  2701.  
  2702.   expand_label (label);
  2703.   return 0;
  2704. }
  2705.  
  2706. /* Like pushcase but this case applies to all values
  2707.    between VALUE1 and VALUE2 (inclusive).
  2708.    The return value is the same as that of pushcase
  2709.    but there is one additional error code:
  2710.    4 means the specified range was empty.
  2711.  
  2712.    Note that this does not currently work, since expand_end_case
  2713.    has yet to be extended to handle RANGE_EXPRs.  */
  2714.  
  2715. int
  2716. pushcase_range (value1, value2, label)
  2717.      register tree value1, value2;
  2718.      register tree label;
  2719. {
  2720.   register struct case_node **l;
  2721.   register struct case_node *n;
  2722.   tree index_type;
  2723.   tree nominal_type;
  2724.  
  2725.   /* Fail if not inside a real case statement.  */
  2726.   if (! (case_stack && case_stack->data.case_stmt.start))
  2727.     return 1;
  2728.  
  2729.   index_type = TREE_TYPE (case_stack->data.case_stmt.index_expr);
  2730.   nominal_type = case_stack->data.case_stmt.nominal_type;
  2731.  
  2732.   /* If the index is erroneous, avoid more problems: pretend to succeed.  */
  2733.   if (index_type == error_mark_node)
  2734.     return 0;
  2735.  
  2736.   /* Convert VALUEs to type in which the comparisons are nominally done.  */
  2737.   if (value1 != 0)
  2738.     value1 = convert (nominal_type, value1);
  2739.   if (value2 != 0)
  2740.     value2 = convert (nominal_type, value2);
  2741.  
  2742.   /* Fail if these values are out of range.  */
  2743.   if (value1 != 0 && ! int_fits_type_p (value1, index_type))
  2744.     return 3;
  2745.  
  2746.   if (value2 != 0 && ! int_fits_type_p (value2, index_type))
  2747.     return 3;
  2748.  
  2749.   /* Fail if the range is empty.  */
  2750.   if (tree_int_cst_lt (value2, value1))
  2751.     return 4;
  2752.  
  2753.   /* If the bounds are equal, turn this into the one-value case.  */
  2754.   if (tree_int_cst_equal (value1, value2))
  2755.     return pushcase (value1, label);
  2756.  
  2757.   /* Find the elt in the chain before which to insert the new value,
  2758.      to keep the chain sorted in increasing order.
  2759.      But report an error if this element is a duplicate.  */
  2760.   for (l = &case_stack->data.case_stmt.case_list;
  2761.        /* Keep going past elements distinctly less than this range.  */
  2762.        *l != 0 && tree_int_cst_lt ((*l)->high, value1);
  2763.        l = &(*l)->right)
  2764.     ;
  2765.   if (*l)
  2766.     {
  2767.       /* Element we will insert before must be distinctly greater;
  2768.      overlap means error.  */
  2769.       if (! tree_int_cst_lt (value2, (*l)->low))
  2770.     return 2;
  2771.     }
  2772.  
  2773.   /* Add this label to the chain, and succeed.
  2774.      Copy VALUE1, VALUE2 so they are on temporary rather than momentary
  2775.      obstack and will thus survive till the end of the case statement.  */
  2776.  
  2777.   n = (struct case_node *) oballoc (sizeof (struct case_node));
  2778.   n->left = 0;
  2779.   n->right = *l;
  2780.   n->low = copy_node (value1);
  2781.   n->high = copy_node (value2);
  2782.   n->code_label = label;
  2783.   n->test_label = 0;
  2784.   *l = n;
  2785.  
  2786.   expand_label (label);
  2787.  
  2788.   case_stack->data.case_stmt.num_ranges++;
  2789.  
  2790.   return 0;
  2791. }
  2792.  
  2793. /* Check that all enumeration literals are covered by the case
  2794.    expressions of a switch.  Also, warn if there are any extra
  2795.    switch cases that are *not* elements of the enumerated type. */
  2796.  
  2797. void
  2798. check_for_full_enumeration_handling (type)
  2799.      tree type;
  2800. {
  2801.   register struct case_node *n;
  2802.   register tree chain;
  2803.  
  2804.   /* The time complexity of this loop is currently O(N * M), with
  2805.      N being the number of enumerals in the enumerated type, and 
  2806.      M being the number of case expressions in the switch. */
  2807.              
  2808.   for (chain = TYPE_VALUES (type);
  2809.        chain;
  2810.        chain = TREE_CHAIN (chain))
  2811.     {
  2812.       /* Find a match between enumeral and case expression, if possible.
  2813.      Quit looking when we've gone too far (since case expressions
  2814.      are kept sorted in ascending order).  Warn about enumerals not
  2815.      handled in the switch statement case expression list. */
  2816.  
  2817.       for (n = case_stack->data.case_stmt.case_list; 
  2818.        n && tree_int_cst_lt (n->high, TREE_VALUE (chain));
  2819.        n = n->right)
  2820.     ;
  2821.  
  2822.       if (!(n && tree_int_cst_equal (n->low, TREE_VALUE (chain))))
  2823.     warning ("enumerated value `%s' not handled in switch",
  2824.          IDENTIFIER_POINTER (TREE_PURPOSE (chain)));
  2825.     }
  2826.  
  2827.   /* Now we go the other way around; we warn if there are case 
  2828.      expressions that don't correspond to enumerals.  This can
  2829.      occur since C and C++ don't enforce type-checking of 
  2830.      assignments to enumeration variables. */
  2831.  
  2832.   for (n = case_stack->data.case_stmt.case_list; n; n = n->right)
  2833.     {
  2834.       for (chain = TYPE_VALUES (type);
  2835.        chain && !tree_int_cst_equal (n->low, TREE_VALUE (chain)); 
  2836.        chain = TREE_CHAIN (chain))
  2837.     ;
  2838.  
  2839.       if (!chain)
  2840.     warning ("case value `%d' not in enumerated type `%s'",
  2841.          TREE_INT_CST_LOW (n->low), 
  2842.          IDENTIFIER_POINTER (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE
  2843.                      ? TYPE_NAME (type)
  2844.                      : DECL_NAME (TYPE_NAME (type))));
  2845.     }
  2846. }
  2847.  
  2848. /* Terminate a case (Pascal) or switch (C) statement
  2849.    in which CASE_INDEX is the expression to be tested.
  2850.    Generate the code to test it and jump to the right place.  */
  2851.  
  2852. void
  2853. expand_end_case (orig_index)
  2854.      tree orig_index;
  2855. {
  2856.   tree minval, maxval, range;
  2857.   rtx default_label = 0;
  2858.   register struct case_node *n;
  2859.   int count;
  2860.   rtx index;
  2861.   rtx table_label = gen_label_rtx ();
  2862.   int ncases;
  2863.   rtx *labelvec;
  2864.   register int i;
  2865.   rtx before_case;
  2866.   register struct nesting *thiscase = case_stack;
  2867.   tree index_expr = thiscase->data.case_stmt.index_expr;
  2868.   int unsignedp = TREE_UNSIGNED (TREE_TYPE (index_expr));
  2869.  
  2870.   do_pending_stack_adjust ();
  2871.  
  2872.   /* An ERROR_MARK occurs for various reasons including invalid data type.  */
  2873.   if (TREE_TYPE (index_expr) != error_mark_node)
  2874.     {
  2875.       /* If switch expression was an enumerated type, check that all
  2876.      enumeration literals are covered by the cases.
  2877.      No sense trying this if there's a default case, however.  */
  2878.  
  2879.       if (!thiscase->data.case_stmt.default_label 
  2880.       && TREE_CODE (TREE_TYPE (orig_index)) == ENUMERAL_TYPE
  2881.       && TREE_CODE (index_expr) != INTEGER_CST
  2882.       && warn_switch)
  2883.     check_for_full_enumeration_handling (TREE_TYPE (orig_index));
  2884.  
  2885.       /* If we don't have a default-label, create one here,
  2886.      after the body of the switch.  */
  2887.       if (thiscase->data.case_stmt.default_label == 0)
  2888.     {
  2889.       thiscase->data.case_stmt.default_label
  2890.         = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
  2891.       expand_label (thiscase->data.case_stmt.default_label);
  2892.     }
  2893.       default_label = label_rtx (thiscase->data.case_stmt.default_label);
  2894.  
  2895.       before_case = get_last_insn ();
  2896.  
  2897.       /* Simplify the case-list before we count it.  */
  2898.       group_case_nodes (thiscase->data.case_stmt.case_list);
  2899.  
  2900.       /* Get upper and lower bounds of case values.
  2901.      Also convert all the case values to the index expr's data type.  */
  2902.  
  2903.       count = 0;
  2904.       for (n = thiscase->data.case_stmt.case_list; n; n = n->right)
  2905.     {
  2906.       /* Check low and high label values are integers.  */
  2907.       if (TREE_CODE (n->low) != INTEGER_CST)
  2908.         abort ();
  2909.       if (TREE_CODE (n->high) != INTEGER_CST)
  2910.         abort ();
  2911.  
  2912.       n->low = convert (TREE_TYPE (index_expr), n->low);
  2913.       n->high = convert (TREE_TYPE (index_expr), n->high);
  2914.  
  2915.       /* Count the elements and track the largest and smallest
  2916.          of them (treating them as signed even if they are not).  */
  2917.       if (count++ == 0)
  2918.         {
  2919.           minval = n->low;
  2920.           maxval = n->high;
  2921.         }
  2922.       else
  2923.         {
  2924.           if (INT_CST_LT (n->low, minval))
  2925.         minval = n->low;
  2926.           if (INT_CST_LT (maxval, n->high))
  2927.         maxval = n->high;
  2928.         }
  2929.       /* A range counts double, since it requires two compares.  */
  2930.       if (! tree_int_cst_equal (n->low, n->high))
  2931.         count++;
  2932.     }
  2933.  
  2934.       /* Compute span of values.  */
  2935.       if (count != 0)
  2936.     range = combine (MINUS_EXPR, maxval, minval);
  2937.  
  2938.       if (count == 0 || TREE_CODE (TREE_TYPE (index_expr)) == ERROR_MARK)
  2939.     {
  2940.       expand_expr (index_expr, const0_rtx, VOIDmode, 0);
  2941.       emit_queue ();
  2942.       emit_jump (default_label);
  2943.     }
  2944.       /* If range of values is much bigger than number of values,
  2945.      make a sequence of conditional branches instead of a dispatch.
  2946.      If the switch-index is a constant, do it this way
  2947.      because we can optimize it.  */
  2948.       else if (TREE_INT_CST_HIGH (range) != 0
  2949. #ifdef HAVE_casesi
  2950.            || count < 4
  2951. #else
  2952.            /* If machine does not have a case insn that compares the
  2953.           bounds, this means extra overhead for dispatch tables
  2954.           which raises the threshold for using them.  */
  2955.            || count < 5
  2956. #endif
  2957.            || (unsigned) (TREE_INT_CST_LOW (range)) > 10 * count
  2958.            || TREE_CODE (index_expr) == INTEGER_CST)
  2959.     {
  2960.       index = expand_expr (index_expr, 0, VOIDmode, 0);
  2961.  
  2962.       /* If the index is a short or char that we do not have
  2963.          an insn to handle comparisons directly, convert it to
  2964.          a full integer now, rather than letting each comparison
  2965.          generate the conversion.  */
  2966.  
  2967.       if ((GET_MODE (index) == QImode || GET_MODE (index) == HImode)
  2968.           && (cmp_optab->handlers[(int) GET_MODE(index)].insn_code
  2969.           == CODE_FOR_nothing))
  2970.         index = convert_to_mode (SImode, index, unsignedp);
  2971.       
  2972.       emit_queue ();
  2973.       do_pending_stack_adjust ();
  2974.  
  2975.       index = protect_from_queue (index, 0);
  2976.       if (GET_CODE (index) == MEM)
  2977.         index = copy_to_reg (index);
  2978.       if (GET_CODE (index) == CONST_INT
  2979.           || TREE_CODE (index_expr) == INTEGER_CST)
  2980.         {
  2981.           /* Make a tree node with the proper constant value
  2982.          if we don't already have one.  */
  2983.           if (TREE_CODE (index_expr) != INTEGER_CST)
  2984.         {
  2985.           index_expr
  2986.             = build_int_2 (INTVAL (index),
  2987.                    !unsignedp && INTVAL (index) >= 0 ? 0 : -1);
  2988.           index_expr = convert (TREE_TYPE (index_expr), index_expr);
  2989.         }
  2990.  
  2991.           /* For constant index expressions we need only
  2992.          issue a unconditional branch to the appropriate
  2993.          target code.  The job of removing any unreachable
  2994.          code is left to the optimisation phase if the
  2995.          "-O" option is specified.  */
  2996.           for (n = thiscase->data.case_stmt.case_list;
  2997.            n;
  2998.            n = n->right)
  2999.         {
  3000.           if (! tree_int_cst_lt (index_expr, n->low)
  3001.               && ! tree_int_cst_lt (n->high, index_expr))
  3002.             break;
  3003.         }
  3004.           if (n)
  3005.         emit_jump (label_rtx (n->code_label));
  3006.           else
  3007.         emit_jump (default_label);
  3008.         }
  3009.       else
  3010.         {
  3011.           /* If the index expression is not constant we generate
  3012.          a binary decision tree to select the appropriate
  3013.          target code.  This is done as follows:
  3014.  
  3015.          The list of cases is rearranged into a binary tree,
  3016.          nearly optimal assuming equal probability for each case.
  3017.  
  3018.          The tree is transformed into RTL, eliminating
  3019.          redundant test conditions at the same time.
  3020.  
  3021.          If program flow could reach the end of the
  3022.          decision tree an unconditional jump to the
  3023.          default code is emitted.  */
  3024.           if (optimize
  3025.           && TREE_CODE (TREE_TYPE (orig_index)) != ENUMERAL_TYPE)
  3026.         estimate_case_costs (thiscase->data.case_stmt.case_list,
  3027.                      default_label);
  3028.           balance_case_nodes (&thiscase->data.case_stmt.case_list, 0);
  3029.           emit_case_nodes (index, thiscase->data.case_stmt.case_list,
  3030.                    default_label, unsignedp);
  3031.           emit_jump_if_reachable (default_label);
  3032.         }
  3033.     }
  3034.       else
  3035.     {
  3036. #ifdef HAVE_casesi
  3037.       /* Convert the index to SImode.  */
  3038.       if (TYPE_MODE (TREE_TYPE (index_expr)) == DImode)
  3039.         {
  3040.           index_expr = build (MINUS_EXPR, TREE_TYPE (index_expr),
  3041.                   index_expr, minval);
  3042.           minval = integer_zero_node;
  3043.         }
  3044.       if (TYPE_MODE (TREE_TYPE (index_expr)) != SImode)
  3045.         index_expr = convert (type_for_size (GET_MODE_BITSIZE (SImode), 0),
  3046.                   index_expr);
  3047.       index = expand_expr (index_expr, 0, VOIDmode, 0);
  3048.       emit_queue ();
  3049.       index = protect_from_queue (index, 0);
  3050.       do_pending_stack_adjust ();
  3051.  
  3052.       emit_jump_insn (gen_casesi (index, expand_expr (minval, 0, VOIDmode, 0),
  3053.                       expand_expr (range, 0, VOIDmode, 0),
  3054.                       table_label, default_label));
  3055. #else
  3056. #ifdef HAVE_tablejump
  3057.       index_expr = convert (type_for_size (GET_MODE_BITSIZE (SImode), 0),
  3058.                 build (MINUS_EXPR, TREE_TYPE (index_expr),
  3059.                        index_expr, minval));
  3060.       index = expand_expr (index_expr, 0, VOIDmode, 0);
  3061.       emit_queue ();
  3062.       index = protect_from_queue (index, 0);
  3063.       do_pending_stack_adjust ();
  3064.  
  3065.       do_tablejump (index,
  3066.             gen_rtx (CONST_INT, VOIDmode, TREE_INT_CST_LOW (range)),
  3067.             table_label, default_label);
  3068. #else
  3069.       lossage;
  3070. #endif                /* not HAVE_tablejump */
  3071. #endif                /* not HAVE_casesi */
  3072.  
  3073.       /* Get table of labels to jump to, in order of case index.  */
  3074.  
  3075.       ncases = TREE_INT_CST_LOW (range) + 1;
  3076.       labelvec = (rtx *) alloca (ncases * sizeof (rtx));
  3077.       bzero (labelvec, ncases * sizeof (rtx));
  3078.  
  3079.       for (n = thiscase->data.case_stmt.case_list; n; n = n->right)
  3080.         {
  3081.           register int i
  3082.         = TREE_INT_CST_LOW (n->low) - TREE_INT_CST_LOW (minval);
  3083.  
  3084.           while (i + TREE_INT_CST_LOW (minval)
  3085.              <= TREE_INT_CST_LOW (n->high))
  3086.         labelvec[i++]
  3087.           = gen_rtx (LABEL_REF, Pmode, label_rtx (n->code_label));
  3088.         }
  3089.  
  3090.       /* Fill in the gaps with the default.  */
  3091.       for (i = 0; i < ncases; i++)
  3092.         if (labelvec[i] == 0)
  3093.           labelvec[i] = gen_rtx (LABEL_REF, Pmode, default_label);
  3094.  
  3095.       /* Output the table */
  3096.       emit_label (table_label);
  3097.  
  3098. #ifdef CASE_VECTOR_PC_RELATIVE
  3099.       emit_jump_insn (gen_rtx (ADDR_DIFF_VEC, CASE_VECTOR_MODE,
  3100.                    gen_rtx (LABEL_REF, Pmode, table_label),
  3101.                    gen_rtvec_v (ncases, labelvec)));
  3102. #else
  3103.       emit_jump_insn (gen_rtx (ADDR_VEC, CASE_VECTOR_MODE,
  3104.                    gen_rtvec_v (ncases, labelvec)));
  3105. #endif
  3106.       /* If the case insn drops through the table,
  3107.          after the table we must jump to the default-label.
  3108.          Otherwise record no drop-through after the table.  */
  3109. #ifdef CASE_DROPS_THROUGH
  3110.       emit_jump (default_label);
  3111. #else
  3112.       emit_barrier ();
  3113. #endif
  3114.     }
  3115.  
  3116.       reorder_insns (NEXT_INSN (before_case), get_last_insn (),
  3117.              thiscase->data.case_stmt.start);
  3118.     }
  3119.   if (thiscase->exit_label)
  3120.     emit_label (thiscase->exit_label);
  3121.  
  3122.   POPSTACK (case_stack);
  3123. }
  3124.  
  3125. /* See case.c for CASE-handling code.  */
  3126.  
  3127. /* Allocate fixed slots in the stack frame of the current function.  */
  3128.  
  3129. /* Return size needed for stack frame based on slots so far allocated.  */
  3130.  
  3131. int
  3132. get_frame_size ()
  3133. {
  3134. #ifdef FRAME_GROWS_DOWNWARD
  3135.   return -frame_offset + STARTING_FRAME_OFFSET;
  3136. #else
  3137.   return frame_offset - STARTING_FRAME_OFFSET;
  3138. #endif
  3139. }
  3140.  
  3141. /* Allocate a stack slot of SIZE bytes and return a MEM rtx for it
  3142.    with machine mode MODE.  */
  3143.  
  3144. rtx
  3145. assign_stack_local (mode, size)
  3146.      enum machine_mode mode;
  3147.      int size;
  3148. {
  3149.   register rtx x, addr;
  3150.   int bigend_correction = 0;
  3151.  
  3152.   frame_pointer_needed = 1;
  3153.  
  3154.   /* Make each stack slot a multiple of the main allocation unit.  */
  3155.   size = (((size + (BIGGEST_ALIGNMENT / BITS_PER_UNIT) - 1)
  3156.        / (BIGGEST_ALIGNMENT / BITS_PER_UNIT))
  3157.       * (BIGGEST_ALIGNMENT / BITS_PER_UNIT));
  3158.  
  3159.   /* On a big-endian machine, if we are allocating more space than we will use,
  3160.      use the least significant bytes of those that are allocated.  */
  3161. #ifdef BYTES_BIG_ENDIAN
  3162.   if (mode != BLKmode)
  3163.     bigend_correction = size - GET_MODE_SIZE (mode);
  3164. #endif
  3165.  
  3166. #ifdef FRAME_GROWS_DOWNWARD
  3167.   frame_offset -= size;
  3168. #endif
  3169.   addr = gen_rtx (PLUS, Pmode, frame_pointer_rtx,
  3170.           gen_rtx (CONST_INT, VOIDmode,
  3171.                (frame_offset + bigend_correction)));
  3172. #ifndef FRAME_GROWS_DOWNWARD
  3173.   frame_offset += size;
  3174. #endif
  3175.  
  3176.   if (! memory_address_p (mode, addr))
  3177.     invalid_stack_slot = 1;
  3178.  
  3179.   x = gen_rtx (MEM, mode, addr);
  3180.  
  3181.   stack_slot_list = gen_rtx (EXPR_LIST, VOIDmode, x, stack_slot_list);
  3182.  
  3183.   return x;
  3184. }
  3185.  
  3186. /* Retroactively move an auto variable from a register to a stack slot.
  3187.    This is done when an address-reference to the variable is seen.  */
  3188.  
  3189. void
  3190. put_var_into_stack (decl)
  3191.      tree decl;
  3192. {
  3193.   register rtx reg = DECL_RTL (decl);
  3194.   register rtx new;
  3195.  
  3196.   /* No need to do anything if decl has no rtx yet
  3197.      since in that case caller is setting TREE_ADDRESSABLE
  3198.      and a stack slot will be assigned when the rtl is made.  */
  3199.   if (reg == 0)
  3200.     return;
  3201.   if (GET_CODE (reg) != REG)
  3202.     return;
  3203.  
  3204.   new = parm_stack_loc (reg);
  3205.   if (new == 0)
  3206.     new = assign_stack_local (GET_MODE (reg), GET_MODE_SIZE (GET_MODE (reg)));
  3207.  
  3208.   XEXP (reg, 0) = XEXP (new, 0);
  3209.   /* `volatil' bit means one thing for MEMs, another entirely for REGs.  */
  3210.   REG_USERVAR_P (reg) = 0;
  3211.   PUT_CODE (reg, MEM);
  3212.  
  3213.   /* If this is a memory ref that contains aggregate components,
  3214.      mark it as such for cse and loop optimize.  */
  3215.   MEM_IN_STRUCT_P (reg)
  3216.     = (TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE
  3217.        || TREE_CODE (TREE_TYPE (decl)) == RECORD_TYPE
  3218.        || TREE_CODE (TREE_TYPE (decl)) == UNION_TYPE);
  3219.  
  3220.   fixup_var_refs (reg);
  3221. }
  3222.  
  3223. static void
  3224. fixup_var_refs (var)
  3225.      rtx var;
  3226. {
  3227.   extern rtx sequence_stack;
  3228.   rtx stack = sequence_stack;
  3229.   tree pending;
  3230.  
  3231.   stack = sequence_stack;
  3232.  
  3233.   /* Must scan all insns for stack-refs that exceed the limit.  */
  3234.   fixup_var_refs_insns (var, get_insns (), stack == 0);
  3235.  
  3236.   /* Scan all pending sequences too.  */
  3237.   for (; stack; stack = XEXP (XEXP (stack, 1), 1))
  3238.     {
  3239.       push_to_sequence (XEXP (stack, 0));
  3240.       fixup_var_refs_insns (var, XEXP (stack, 0),
  3241.                 XEXP (XEXP (stack, 1), 1) == 0);
  3242.       /* Update remembered end of sequence
  3243.      in case we added an insn at the end.  */
  3244.       XEXP (XEXP (stack, 1), 0) = get_last_insn ();
  3245.       end_sequence ();
  3246.     }
  3247.  
  3248.   /* Scan all waiting RTL_EXPRs too.  */
  3249.   for (pending = rtl_expr_chain; pending; pending = TREE_CHAIN (pending))
  3250.     {
  3251.       rtx seq = RTL_EXPR_SEQUENCE (TREE_VALUE (pending));
  3252.       if (seq != const0_rtx && seq != 0)
  3253.     {
  3254.       push_to_sequence (seq);
  3255.       fixup_var_refs_insns (var, seq, 0);
  3256.       end_sequence ();
  3257.     }
  3258.     }
  3259. }
  3260.  
  3261. /* Scan the insn-chain starting with INSN for refs to VAR
  3262.    and fix them up.  TOPLEVEL is nonzero if this chain is the
  3263.    main chain of insns for the current function.  */
  3264.  
  3265. static void
  3266. fixup_var_refs_insns (var, insn, toplevel)
  3267.      rtx var;
  3268.      rtx insn;
  3269.      int toplevel;
  3270. {
  3271.   while (insn)
  3272.     {
  3273.       rtx next = NEXT_INSN (insn);
  3274.       rtx note;
  3275.       if (GET_CODE (insn) == INSN || GET_CODE (insn) == CALL_INSN
  3276.       || GET_CODE (insn) == JUMP_INSN)
  3277.     {
  3278.       /* The insn to load VAR from a home in the arglist
  3279.          is now a no-op.  When we see it, just delete it.  */
  3280.       if (toplevel
  3281.           && GET_CODE (PATTERN (insn)) == SET
  3282.           && SET_DEST (PATTERN (insn)) == var
  3283.           && rtx_equal_p (SET_SRC (PATTERN (insn)), var))
  3284.         {
  3285.           next = delete_insn (insn);
  3286.           if (insn == last_parm_insn)
  3287.         last_parm_insn = PREV_INSN (next);
  3288.         }
  3289.       else
  3290.         fixup_var_refs_1 (var, PATTERN (insn), insn);
  3291.       /* Also fix up any invalid exprs in the REG_NOTES of this insn.
  3292.          But don't touch other insns referred to by reg-notes;
  3293.          we will get them elsewhere.  */
  3294.       for (note = REG_NOTES (insn); note; note = XEXP (note, 1))
  3295.         if (GET_CODE (note) != INSN_LIST)
  3296.           XEXP (note, 0) = walk_fixup_memory_subreg (XEXP (note, 0), insn);
  3297.     }
  3298.       insn = next;
  3299.     }
  3300. }
  3301.  
  3302. static rtx
  3303. fixup_var_refs_1 (var, x, insn)
  3304.      register rtx var;
  3305.      register rtx x;
  3306.      rtx insn;
  3307. {
  3308.   register int i;
  3309.   RTX_CODE code = GET_CODE (x);
  3310.   register char *fmt;
  3311.   register rtx tem;
  3312.  
  3313.   switch (code)
  3314.     {
  3315.     case MEM:
  3316.       if (var == x)
  3317.     {
  3318.       x = fixup_stack_1 (x, insn);
  3319.       tem = gen_reg_rtx (GET_MODE (x));
  3320.       /* Put new insn before a CALL, before any USEs before it.  */
  3321.       if (GET_CODE (insn) == CALL_INSN)
  3322.         while (PREV_INSN (insn) != 0 && GET_CODE (PREV_INSN (insn)) == INSN
  3323.            && GET_CODE (PATTERN (PREV_INSN (insn))) == USE)
  3324.           insn = PREV_INSN (insn);
  3325.       emit_insn_before (gen_move_insn (tem, x), insn);
  3326.       return tem;
  3327.     }
  3328.       break;
  3329.  
  3330.     case REG:
  3331.     case CC0:
  3332.     case PC:
  3333.     case CONST_INT:
  3334.     case CONST:
  3335.     case SYMBOL_REF:
  3336.     case LABEL_REF:
  3337.     case CONST_DOUBLE:
  3338.       return x;
  3339.  
  3340.     case SIGN_EXTRACT:
  3341.     case ZERO_EXTRACT:
  3342.       /* Note that in some cases those types of expressions are altered
  3343.      by optimize_bit_field, and do not survive to get here.  */
  3344.     case SUBREG:
  3345.       tem = x;
  3346.       while (GET_CODE (tem) == SUBREG || GET_CODE (tem) == SIGN_EXTRACT
  3347.          || GET_CODE (tem) == ZERO_EXTRACT)
  3348.     tem = XEXP (tem, 0);
  3349.       if (tem == var)
  3350.     {
  3351.       x = fixup_stack_1 (x, insn);
  3352.       tem = gen_reg_rtx (GET_MODE (x));
  3353.       if (GET_CODE (x) == SUBREG)
  3354.         x = fixup_memory_subreg (x, insn);
  3355.       emit_insn_before (gen_move_insn (tem, x), insn);
  3356.       return tem;
  3357.     }
  3358.       break;
  3359.  
  3360.     case SET:
  3361.       /* First do special simplification of bit-field references.  */
  3362.       if (GET_CODE (SET_DEST (x)) == SIGN_EXTRACT
  3363.       || GET_CODE (SET_DEST (x)) == ZERO_EXTRACT)
  3364.     optimize_bit_field (x, insn, 0);
  3365.       if (GET_CODE (SET_SRC (x)) == SIGN_EXTRACT
  3366.       || GET_CODE (SET_SRC (x)) == ZERO_EXTRACT)
  3367.     optimize_bit_field (x, insn, 0);
  3368.  
  3369.       {
  3370.     rtx dest = SET_DEST (x);
  3371.     rtx src = SET_SRC (x);
  3372.     rtx outerdest = dest;
  3373.     rtx outersrc = src;
  3374.  
  3375.     while (GET_CODE (dest) == SUBREG || GET_CODE (dest) == STRICT_LOW_PART
  3376.            || GET_CODE (dest) == SIGN_EXTRACT
  3377.            || GET_CODE (dest) == ZERO_EXTRACT)
  3378.       dest = XEXP (dest, 0);
  3379.     while (GET_CODE (src) == SUBREG
  3380.            || GET_CODE (src) == SIGN_EXTRACT
  3381.            || GET_CODE (src) == ZERO_EXTRACT)
  3382.       src = XEXP (src, 0);
  3383.  
  3384.     /* If VAR does not appear at the top level of the SET
  3385.        just scan the lower levels of the tree.  */
  3386.  
  3387.         if (src != var && dest != var)
  3388.       break;
  3389.  
  3390.     /* Clean up (SUBREG:SI (MEM:mode ...) 0)
  3391.        that may appear inside a SIGN_EXTRACT or ZERO_EXTRACT.
  3392.        This was legitimate when the MEM was a REG.  */
  3393.  
  3394.     if ((GET_CODE (outerdest) == SIGN_EXTRACT
  3395.          || GET_CODE (outerdest) == ZERO_EXTRACT)
  3396.         && GET_CODE (XEXP (outerdest, 0)) == SUBREG
  3397.         && SUBREG_REG (XEXP (outerdest, 0)) == var)
  3398.       XEXP (outerdest, 0) = fixup_memory_subreg (XEXP (outerdest, 0), insn);
  3399.  
  3400.     if ((GET_CODE (outersrc) == SIGN_EXTRACT
  3401.          || GET_CODE (outersrc) == ZERO_EXTRACT)
  3402.         && GET_CODE (XEXP (outersrc, 0)) == SUBREG
  3403.         && SUBREG_REG (XEXP (outersrc, 0)) == var)
  3404.       XEXP (outersrc, 0) = fixup_memory_subreg (XEXP (outersrc, 0), insn);
  3405.  
  3406.     /* Make sure that the machine's SIGN_EXTRACT and ZERO_EXTRACT insns
  3407.        accept a memory operand.  */
  3408. #ifdef HAVE_extzv
  3409.     if (GET_CODE (outersrc) == ZERO_EXTRACT
  3410.         && ! ((*insn_operand_predicate[(int) CODE_FOR_extzv][0])
  3411.           (XEXP (outersrc, 0), VOIDmode)))
  3412.       XEXP (outersrc, 0) = src
  3413.         = fixup_var_refs_1 (var, XEXP (outersrc, 0), insn);
  3414. #endif
  3415. #ifdef HAVE_extv
  3416.     if (GET_CODE (outersrc) == SIGN_EXTRACT
  3417.         && ! ((*insn_operand_predicate[(int) CODE_FOR_extv][0])
  3418.           (XEXP (outersrc, 0), VOIDmode)))
  3419.       XEXP (outersrc, 0) = src
  3420.         = fixup_var_refs_1 (var, XEXP (outersrc, 0), insn);
  3421. #endif
  3422. #ifdef HAVE_insv
  3423.     if (GET_CODE (outerdest) == ZERO_EXTRACT
  3424.         && ! ((*insn_operand_predicate[(int) CODE_FOR_insv][0])
  3425.           (XEXP (outerdest, 0), VOIDmode)))
  3426.       {
  3427.         rtx tem = gen_reg_rtx (GET_MODE (XEXP (outerdest, 0)));
  3428.  
  3429.         emit_insn_before (gen_move_insn (tem, XEXP (outerdest, 0)), insn);
  3430.         emit_insn_after (gen_move_insn (XEXP (outerdest, 0), tem), insn);
  3431.         dest = XEXP (outerdest, 0) = tem;
  3432.       }
  3433. #endif
  3434.  
  3435.     /* Make sure a MEM inside a SIGN_EXTRACT has QImode
  3436.        since that's what bit-field insns want.  */
  3437.  
  3438.     if ((GET_CODE (outerdest) == SIGN_EXTRACT
  3439.          || GET_CODE (outerdest) == ZERO_EXTRACT)
  3440.         && GET_CODE (XEXP (outerdest, 0)) == MEM
  3441.         && GET_MODE (XEXP (outerdest, 0)) != QImode)
  3442.       {
  3443.         XEXP (outerdest, 0) = copy_rtx (XEXP (outerdest, 0));
  3444.         PUT_MODE (XEXP (outerdest, 0), QImode);
  3445.         /* Adjust the address so the bit field starts within the byte
  3446.            addressed.  This helps certain optimization patterns.  */
  3447.         if (GET_CODE (XEXP (outerdest, 2)) == CONST_INT
  3448.         && offsettable_memref_p (XEXP (outerdest, 0)))
  3449.           {
  3450.         int count = INTVAL (XEXP (outerdest, 2));
  3451.         XEXP (outerdest, 0)
  3452.           = adj_offsettable_operand (XEXP (outerdest, 0),
  3453.                          count / GET_MODE_BITSIZE (QImode));
  3454.         XEXP (outerdest, 2)
  3455.           = gen_rtx (CONST_INT, VOIDmode,
  3456.                  count % GET_MODE_BITSIZE (QImode));
  3457.           }
  3458.       }
  3459.  
  3460.     if ((GET_CODE (outersrc) == SIGN_EXTRACT
  3461.          || GET_CODE (outersrc) == ZERO_EXTRACT)
  3462.         && GET_CODE (XEXP (outersrc, 0)) == MEM
  3463.         && GET_MODE (XEXP (outersrc, 0)) != QImode)
  3464.       {
  3465.         XEXP (outersrc, 0) = copy_rtx (XEXP (outersrc, 0));
  3466.         PUT_MODE (XEXP (outersrc, 0), QImode);
  3467.         /* Adjust the address so the bit field starts within the byte
  3468.            addressed.  This helps certain optimization patterns.  */
  3469.         if (GET_CODE (XEXP (outersrc, 2)) == CONST_INT
  3470.         && offsettable_memref_p (XEXP (outersrc, 0)))
  3471.           {
  3472.         int count = INTVAL (XEXP (outersrc, 2));
  3473.         XEXP (outersrc, 0)
  3474.           = adj_offsettable_operand (XEXP (outersrc, 0),
  3475.                          count / GET_MODE_BITSIZE (QImode));
  3476.         XEXP (outersrc, 2)
  3477.           = gen_rtx (CONST_INT, VOIDmode,
  3478.                  count % GET_MODE_BITSIZE (QImode));
  3479.           }
  3480.       }
  3481.  
  3482.     /* STRICT_LOW_PART is a no-op on memory references
  3483.        and it can cause combinations to be unrecognizable,
  3484.        so eliminate it.  */
  3485.  
  3486.     if (dest == var && GET_CODE (SET_DEST (x)) == STRICT_LOW_PART)
  3487.       SET_DEST (x) = XEXP (SET_DEST (x), 0);
  3488.  
  3489.     /* An insn to copy VAR into or out of a register
  3490.        must be left alone, to avoid an infinite loop here.
  3491.        But do fix up the address of VAR's stack slot if nec,
  3492.        and fix up SUBREGs containing VAR
  3493.        (since they are now memory subregs).  */
  3494.  
  3495.     if (GET_CODE (SET_SRC (x)) == REG || GET_CODE (SET_DEST (x)) == REG
  3496.         || (GET_CODE (SET_SRC (x)) == SUBREG
  3497.         && GET_CODE (SUBREG_REG (SET_SRC (x))) == REG)
  3498.         || (GET_CODE (SET_DEST (x)) == SUBREG
  3499.         && GET_CODE (SUBREG_REG (SET_DEST (x))) == REG))
  3500.       {
  3501.         if (src == var && GET_CODE (SET_SRC (x)) == SUBREG)
  3502.           SET_SRC (x) = fixup_memory_subreg (SET_SRC (x), insn);
  3503.         if (dest == var && GET_CODE (SET_DEST (x)) == SUBREG)
  3504.           SET_DEST (x) = fixup_memory_subreg (SET_DEST (x), insn);
  3505.         return fixup_stack_1 (x, insn);
  3506.       }
  3507.  
  3508.     /* Otherwise, storing into VAR must be handled specially
  3509.        by storing into a temporary and copying that into VAR
  3510.        with a new insn after this one.  */
  3511.  
  3512.     if (dest == var)
  3513.       {
  3514.         rtx temp;
  3515.         rtx fixeddest;
  3516.         tem = SET_DEST (x);
  3517.         /* STRICT_LOW_PART can be discarded, around a MEM.  */
  3518.         if (GET_CODE (tem) == STRICT_LOW_PART)
  3519.           tem = XEXP (tem, 0);
  3520.         /* Convert (SUBREG (MEM)) to a MEM in a changed mode.  */
  3521.         if (GET_CODE (tem) == SUBREG)
  3522.           tem = fixup_memory_subreg (tem, insn);
  3523.         fixeddest = fixup_stack_1 (tem, insn);
  3524.         temp = gen_reg_rtx (GET_MODE (tem));
  3525.         emit_insn_after (gen_move_insn (fixeddest, temp), insn);
  3526.         SET_DEST (x) = temp;
  3527.       }
  3528.       }
  3529.     }
  3530.  
  3531.   /* Nothing special about this RTX; fix its operands.  */
  3532.  
  3533.   fmt = GET_RTX_FORMAT (code);
  3534.   for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
  3535.     {
  3536.       if (fmt[i] == 'e')
  3537.     XEXP (x, i) = fixup_var_refs_1 (var, XEXP (x, i), insn);
  3538.       if (fmt[i] == 'E')
  3539.     {
  3540.       register int j;
  3541.       for (j = 0; j < XVECLEN (x, i); j++)
  3542.         XVECEXP (x, i, j)
  3543.           = fixup_var_refs_1 (var, XVECEXP (x, i, j), insn);
  3544.     }
  3545.     }
  3546.   return x;
  3547. }
  3548.  
  3549. /* Given X, an rtx of the form (SUBREG:m1 (MEM:m2 addr)),
  3550.    return an rtx (MEM:m1 newaddr) which is equivalent.
  3551.    If any insns must be emitted to compute NEWADDR, put them before INSN.  */
  3552.  
  3553. static rtx
  3554. fixup_memory_subreg (x, insn)
  3555.      rtx x;
  3556.      rtx insn;
  3557. {
  3558.   int offset = SUBREG_WORD (x) * UNITS_PER_WORD;
  3559.   rtx addr = XEXP (SUBREG_REG (x), 0);
  3560.   enum machine_mode mode = GET_MODE (x);
  3561.   rtx saved, result;
  3562.  
  3563. #ifdef BYTES_BIG_ENDIAN
  3564.   offset += (MIN (UNITS_PER_WORD, GET_MODE_SIZE (GET_MODE (SUBREG_REG (x))))
  3565.          - MIN (UNITS_PER_WORD, GET_MODE_SIZE (mode)));
  3566. #endif
  3567.   addr = plus_constant (addr, offset);
  3568.   if (memory_address_p (mode, addr))
  3569.     return change_address (SUBREG_REG (x), mode, addr);
  3570.   saved = start_sequence ();
  3571.   result = change_address (SUBREG_REG (x), mode, addr);
  3572.   emit_insn_before (gen_sequence (), insn);
  3573.   end_sequence (saved);
  3574.   return result;
  3575. }
  3576.  
  3577. /* Do fixup_memory_subreg on all (SUBREG (MEM ...) ...) contained in X.
  3578.    Replace subexpressions of X in place.
  3579.    If X itself is a (SUBREG (MEM ...) ...), return the replacement expression.
  3580.    Otherwise return X, with its contents possibly altered.
  3581.  
  3582.    If any insns must be emitted to compute NEWADDR, put them before INSN.  */
  3583.  
  3584. static rtx
  3585. walk_fixup_memory_subreg (x, insn)
  3586.      register rtx x;
  3587.      rtx insn;
  3588. {
  3589.   register enum rtx_code code;
  3590.   register char *fmt;
  3591.   register int i;
  3592.  
  3593.   if (x == 0)
  3594.     return 0;
  3595.  
  3596.   code = GET_CODE (x);
  3597.  
  3598.   if (code == SUBREG && GET_CODE (SUBREG_REG (x)) == MEM)
  3599.     return fixup_memory_subreg (x, insn);
  3600.  
  3601.   /* Nothing special about this RTX; fix its operands.  */
  3602.  
  3603.   fmt = GET_RTX_FORMAT (code);
  3604.   for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
  3605.     {
  3606.       if (fmt[i] == 'e')
  3607.     XEXP (x, i) = walk_fixup_memory_subreg (XEXP (x, i), insn);
  3608.       if (fmt[i] == 'E')
  3609.     {
  3610.       register int j;
  3611.       for (j = 0; j < XVECLEN (x, i); j++)
  3612.         XVECEXP (x, i, j)
  3613.           = walk_fixup_memory_subreg (XVECEXP (x, i, j), insn);
  3614.     }
  3615.     }
  3616.   return x;
  3617. }
  3618.  
  3619. #if 0
  3620. /* Fix up any references to stack slots that are invalid memory addresses
  3621.    because they exceed the maximum range of a displacement.  */
  3622.  
  3623. void
  3624. fixup_stack_slots ()
  3625. {
  3626.   register rtx insn;
  3627.  
  3628.   /* Did we generate a stack slot that is out of range
  3629.      or otherwise has an invalid address?  */
  3630.   if (invalid_stack_slot)
  3631.     {
  3632.       /* Yes.  Must scan all insns for stack-refs that exceed the limit.  */
  3633.       for (insn = get_insns (); insn; insn = NEXT_INSN (insn))
  3634.     if (GET_CODE (insn) == INSN || GET_CODE (insn) == CALL_INSN
  3635.         || GET_CODE (insn) == JUMP_INSN)
  3636.       fixup_stack_1 (PATTERN (insn), insn);
  3637.     }
  3638. }
  3639. #endif
  3640.  
  3641. /* For each memory ref within X, if it refers to a stack slot
  3642.    with an out of range displacement, put the address in a temp register
  3643.    (emitting new insns before INSN to load these registers)
  3644.    and alter the memory ref to use that register.
  3645.    Replace each such MEM rtx with a copy, to avoid clobberage.  */
  3646.  
  3647. static rtx
  3648. fixup_stack_1 (x, insn)
  3649.      rtx x;
  3650.      rtx insn;
  3651. {
  3652.   register int i;
  3653.   register RTX_CODE code = GET_CODE (x);
  3654.   register char *fmt;
  3655.  
  3656.   if (code == MEM)
  3657.     {
  3658.       register rtx ad = XEXP (x, 0);
  3659.       /* If we have address of a stack slot but it's not valid
  3660.      (displacement is too large), compute the sum in a register.  */
  3661.       if (GET_CODE (ad) == PLUS
  3662.       && XEXP (ad, 0) == frame_pointer_rtx
  3663.       && GET_CODE (XEXP (ad, 1)) == CONST_INT)
  3664.     {
  3665.       rtx temp;
  3666.       if (memory_address_p (GET_MODE (x), ad))
  3667.         return x;
  3668.       temp = gen_reg_rtx (GET_MODE (ad));
  3669.       emit_insn_before (gen_move_insn (temp, ad), insn);
  3670.       return change_address (x, VOIDmode, temp);
  3671.     }
  3672.       return x;
  3673.     }
  3674.  
  3675.   fmt = GET_RTX_FORMAT (code);
  3676.   for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
  3677.     {
  3678.       if (fmt[i] == 'e')
  3679.     XEXP (x, i) = fixup_stack_1 (XEXP (x, i), insn);
  3680.       if (fmt[i] == 'E')
  3681.     {
  3682.       register int j;
  3683.       for (j = 0; j < XVECLEN (x, i); j++)
  3684.         XVECEXP (x, i, j) = fixup_stack_1 (XVECEXP (x, i, j), insn);
  3685.     }
  3686.     }
  3687.   return x;
  3688. }
  3689.  
  3690. /* Optimization: a bit-field instruction whose field
  3691.    happens to be a byte or halfword in memory
  3692.    can be changed to a move instruction.
  3693.  
  3694.    We call here when INSN is an insn to examine or store into a bit-field.
  3695.    BODY is the SET-rtx to be altered.
  3696.  
  3697.    EQUIV_MEM is the table `reg_equiv_mem' if that is available; else 0.
  3698.    (Currently this is called only from stmt.c, and EQUIV_MEM is always 0.)  */
  3699.  
  3700. static void
  3701. optimize_bit_field (body, insn, equiv_mem)
  3702.      rtx body;
  3703.      rtx insn;
  3704.      rtx *equiv_mem;
  3705. {
  3706.   register rtx bitfield;
  3707.   int destflag;
  3708.  
  3709.   if (GET_CODE (SET_DEST (body)) == SIGN_EXTRACT
  3710.       || GET_CODE (SET_DEST (body)) == ZERO_EXTRACT)
  3711.     bitfield = SET_DEST (body), destflag = 1;
  3712.   else
  3713.     bitfield = SET_SRC (body), destflag = 0;
  3714.  
  3715.   /* First check that the field being stored has constant size and position
  3716.      and is in fact a byte or halfword suitably aligned.  */
  3717.  
  3718.   if (GET_CODE (XEXP (bitfield, 1)) == CONST_INT
  3719.       && GET_CODE (XEXP (bitfield, 2)) == CONST_INT
  3720.       && (INTVAL (XEXP (bitfield, 1)) == GET_MODE_BITSIZE (QImode)
  3721.       || INTVAL (XEXP (bitfield, 1)) == GET_MODE_BITSIZE (HImode))
  3722.       && INTVAL (XEXP (bitfield, 2)) % INTVAL (XEXP (bitfield, 1)) == 0)
  3723.     {
  3724.       register rtx memref = 0;
  3725.  
  3726.       /* Now check that the containing word is memory, not a register,
  3727.      and that it is safe to change the machine mode and to
  3728.      add something to the address.  */
  3729.  
  3730.       if (GET_CODE (XEXP (bitfield, 0)) == MEM)
  3731.     memref = XEXP (bitfield, 0);
  3732.       else if (GET_CODE (XEXP (bitfield, 0)) == REG
  3733.            && equiv_mem != 0)
  3734.     memref = equiv_mem[REGNO (XEXP (bitfield, 0))];
  3735.       else if (GET_CODE (XEXP (bitfield, 0)) == SUBREG
  3736.            && GET_CODE (SUBREG_REG (XEXP (bitfield, 0))) == MEM)
  3737.     memref = SUBREG_REG (XEXP (bitfield, 0));
  3738.       else if (GET_CODE (XEXP (bitfield, 0)) == SUBREG
  3739.            && equiv_mem != 0
  3740.            && GET_CODE (SUBREG_REG (XEXP (bitfield, 0))) == REG)
  3741.     memref = equiv_mem[REGNO (SUBREG_REG (XEXP (bitfield, 0)))];
  3742.  
  3743.       if (memref
  3744.       && ! mode_dependent_address_p (XEXP (memref, 0))
  3745.       && offsettable_address_p (0, GET_MODE (bitfield), XEXP (memref, 0)))
  3746.     {
  3747.       /* Now adjust the address, first for any subreg'ing
  3748.          that we are now getting rid of,
  3749.          and then for which byte of the word is wanted.  */
  3750.  
  3751.       register int offset
  3752.         = INTVAL (XEXP (bitfield, 2)) / GET_MODE_BITSIZE (QImode);
  3753.       if (GET_CODE (XEXP (bitfield, 0)) == SUBREG)
  3754.         {
  3755.           offset += SUBREG_WORD (XEXP (bitfield, 0)) * UNITS_PER_WORD;
  3756. #ifdef BYTES_BIG_ENDIAN
  3757.           offset -= (MIN (UNITS_PER_WORD,
  3758.                   GET_MODE_SIZE (GET_MODE (XEXP (bitfield, 0))))
  3759.              - MIN (UNITS_PER_WORD,
  3760.                 GET_MODE_SIZE (GET_MODE (memref))));
  3761. #endif
  3762.         }
  3763.  
  3764.       memref = gen_rtx (MEM,
  3765.                 (INTVAL (XEXP (bitfield, 1)) == GET_MODE_BITSIZE (QImode)
  3766.                  ? QImode : HImode),
  3767.                 XEXP (memref, 0));
  3768.  
  3769.       /* Store this memory reference where
  3770.          we found the bit field reference.  */
  3771.  
  3772.       if (destflag)
  3773.         {
  3774.           SET_DEST (body)
  3775.         = adj_offsettable_operand (memref, offset);
  3776.           if (! CONSTANT_ADDRESS_P (SET_SRC (body)))
  3777.         {
  3778.           rtx src = SET_SRC (body);
  3779.           while (GET_CODE (src) == SUBREG
  3780.              && SUBREG_WORD (src) == 0)
  3781.             src = SUBREG_REG (src);
  3782.           if (GET_MODE (src) != GET_MODE (memref))
  3783.             src = gen_lowpart (GET_MODE (memref), SET_SRC (body));
  3784.           SET_SRC (body) = src;
  3785.         }
  3786.           else if (GET_MODE (SET_SRC (body)) != VOIDmode
  3787.                && GET_MODE (SET_SRC (body)) != GET_MODE (memref))
  3788.         /* This shouldn't happen because anything that didn't have
  3789.            one of these modes should have got converted explicitly
  3790.            and then referenced through a subreg.
  3791.            This is so because the original bit-field was
  3792.            handled by agg_mode and so its tree structure had
  3793.            the same mode that memref now has.  */
  3794.         abort ();
  3795.         }
  3796.       else
  3797.         {
  3798.           rtx dest = SET_DEST (body);
  3799.  
  3800.           while (GET_CODE (dest) == SUBREG
  3801.              && SUBREG_WORD (dest) == 0)
  3802.         dest = SUBREG_REG (dest);
  3803.           SET_DEST (body) = dest;
  3804.  
  3805.           memref = adj_offsettable_operand (memref, offset);
  3806.           if (GET_MODE (dest) == GET_MODE (memref))
  3807.         SET_SRC (body) = memref;
  3808.           else
  3809.         {
  3810.           /* Convert the mem ref to the destination mode.  */
  3811.           rtx last = get_last_insn ();
  3812.           rtx newreg = gen_reg_rtx (GET_MODE (dest));
  3813.           convert_move (newreg, memref,
  3814.                 GET_CODE (SET_SRC (body)) == ZERO_EXTRACT);
  3815.           /* Put the conversion before the insn being fixed.  */
  3816.           reorder_insns (NEXT_INSN (last), get_last_insn (),
  3817.                  PREV_INSN (insn));
  3818.           SET_SRC (body) = newreg;
  3819.         }
  3820.         }
  3821.  
  3822.       /* Cause the insn to be re-recognized.  */
  3823.  
  3824.       INSN_CODE (insn) = -1;
  3825.     }
  3826.     }
  3827. }
  3828.  
  3829. /* 1 + last pseudo register number used for loading a copy
  3830.    of a parameter of this function.  */
  3831.  
  3832. static int max_parm_reg;
  3833.  
  3834. /* Vector indexed by REGNO, containing location on stack in which
  3835.    to put the parm which is nominally in pseudo register REGNO,
  3836.    if we discover that that parm must go in the stack.  */
  3837. static rtx *parm_reg_stack_loc;
  3838.  
  3839. int
  3840. max_parm_reg_num ()
  3841. {
  3842.   return max_parm_reg;
  3843. }
  3844.  
  3845. /* Return the first insn following those generated by `assign_parms'.  */
  3846.  
  3847. rtx
  3848. get_first_nonparm_insn ()
  3849. {
  3850.   if (last_parm_insn)
  3851.     return NEXT_INSN (last_parm_insn);
  3852.   return get_insns ();
  3853. }
  3854.  
  3855. /* Get the stack home of a REG rtx that is one of this function's parameters.
  3856.    This is called rather than assign a new stack slot as a local.
  3857.    Return 0 if there is no existing stack home suitable for such use.  */
  3858.  
  3859. static rtx
  3860. parm_stack_loc (reg)
  3861.      rtx reg;
  3862. {
  3863.   if (REGNO (reg) < max_parm_reg)
  3864.     return parm_reg_stack_loc[REGNO (reg)];
  3865.   return 0;
  3866. }
  3867.  
  3868. /* Return 1 if EXP returns an aggregate value, for which an address
  3869.    must be passed to the function or returned by the function.  */
  3870.  
  3871. int
  3872. aggregate_value_p (exp)
  3873.      tree exp;
  3874. {
  3875.   if (TYPE_MODE (TREE_TYPE (exp)) == BLKmode)
  3876.     return 1;
  3877.   if (RETURN_IN_MEMORY (TREE_TYPE (exp)))
  3878.     return 1;
  3879.   if (flag_pcc_struct_return
  3880.       && (TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE
  3881.       || TREE_CODE (TREE_TYPE (exp)) == UNION_TYPE))
  3882.     return 1;
  3883.   return 0;
  3884. }
  3885.  
  3886. /* Convert a mem ref into one with a valid memory address.
  3887.    Pass through anything else unchanged.  */
  3888.  
  3889. rtx
  3890. validize_mem (ref)
  3891.      rtx ref;
  3892. {
  3893.   if (GET_CODE (ref) != MEM)
  3894.     return ref;
  3895.   if (memory_address_p (GET_MODE (ref), XEXP (ref, 0)))
  3896.     return ref;
  3897.   return change_address (ref, VOIDmode,
  3898.              memory_address (GET_MODE (ref), XEXP (ref, 0)));
  3899. }
  3900.  
  3901. /* Assign RTL expressions to the function's parameters.
  3902.    This may involve copying them into registers and using
  3903.    those registers as the RTL for them.  */
  3904.  
  3905. static void
  3906. assign_parms (fndecl)
  3907.      tree fndecl;
  3908. {
  3909.   register tree parm;
  3910.   register rtx entry_parm;
  3911.   register rtx stack_parm;
  3912.   register CUMULATIVE_ARGS args_so_far;
  3913.   enum machine_mode passed_mode, nominal_mode;
  3914.   /* Total space needed so far for args on the stack,
  3915.      given as a constant and a tree-expression.  */
  3916.   struct args_size stack_args_size;
  3917.   int first_parm_offset = FIRST_PARM_OFFSET (fndecl);
  3918.   tree fntype = TREE_TYPE (fndecl);
  3919.   /* This is used for the arg pointer when referring to stack args.  */
  3920.   rtx internal_arg_pointer;
  3921.  
  3922.   int nparmregs
  3923.     = list_length (DECL_ARGUMENTS (fndecl)) + FIRST_PSEUDO_REGISTER;
  3924.  
  3925.   /* Nonzero if function takes extra anonymous args.
  3926.      This means the last named arg must be on the stack
  3927.      right before the anonymous ones.
  3928.      Also nonzero if the first arg is named `__builtin_va_alist',
  3929.      which is used on some machines for old-fashioned non-ANSI varargs.h;
  3930.      this too should be stuck onto the stack as if it had arrived there.  */
  3931.   int vararg
  3932.     = ((DECL_ARGUMENTS (fndecl) != 0
  3933.     && DECL_NAME (DECL_ARGUMENTS (fndecl))
  3934.     && (! strcmp (IDENTIFIER_POINTER (DECL_NAME (DECL_ARGUMENTS (fndecl))),
  3935.               "__builtin_va_alist")))
  3936.        ||
  3937.        (TYPE_ARG_TYPES (fntype) != 0
  3938.     && (TREE_VALUE (tree_last (TYPE_ARG_TYPES (fntype)))
  3939.         != void_type_node)));
  3940.   int arg_pointer_copied = 0;
  3941.  
  3942. #if ARG_POINTER_REGNUM == FRAME_POINTER_REGNUM
  3943.   internal_arg_pointer = arg_pointer_rtx;
  3944. #else
  3945.   /* If the arg pointer reg is not a fixed reg,
  3946.      make a copy of it, and address parms via the copy.  */
  3947.   if (fixed_regs[ARG_POINTER_REGNUM])
  3948.     internal_arg_pointer = arg_pointer_rtx;
  3949.   else
  3950.     {
  3951.       internal_arg_pointer = copy_to_reg (arg_pointer_rtx);
  3952.       arg_pointer_copied = 1;
  3953.     }
  3954. #endif
  3955.  
  3956.   stack_args_size.constant = 0;
  3957.   stack_args_size.var = 0;
  3958.  
  3959.   /* If struct value address comes on the stack, count it in size of args.  */
  3960.   if (aggregate_value_p (DECL_RESULT (fndecl))
  3961.       && GET_CODE (struct_value_incoming_rtx) == MEM)
  3962.     stack_args_size.constant += GET_MODE_SIZE (Pmode);
  3963.  
  3964.   parm_reg_stack_loc = (rtx *) oballoc (nparmregs * sizeof (rtx));
  3965.   bzero (parm_reg_stack_loc, nparmregs * sizeof (rtx));
  3966.  
  3967.   INIT_CUMULATIVE_ARGS (args_so_far, fntype);
  3968.  
  3969.   for (parm = DECL_ARGUMENTS (fndecl); parm; parm = TREE_CHAIN (parm))
  3970.     {
  3971.       int aggregate
  3972.     = (TREE_CODE (TREE_TYPE (parm)) == ARRAY_TYPE
  3973.        || TREE_CODE (TREE_TYPE (parm)) == RECORD_TYPE
  3974.        || TREE_CODE (TREE_TYPE (parm)) == UNION_TYPE);
  3975.       struct args_size stack_offset;
  3976.       rtx stack_offset_rtx;
  3977.       enum direction where_pad;
  3978.       /* Extra bytes to add in after parameter is assigned, in
  3979.      case where argument cannot be assigned an offsetted
  3980.      location.  For example, BLKmode parameters cannot be
  3981.      other than on a word boundary (no matter the size)
  3982.      because `access_parm_map' does not know how to handle
  3983.      that case.  */
  3984.       int extra = 0;
  3985.  
  3986.       DECL_OFFSET (parm) = -1;
  3987.  
  3988.       if (TREE_TYPE (parm) == error_mark_node
  3989.       /* This can happen after weird syntax errors
  3990.          or if an enum type is defined among the parms.  */
  3991.       || TREE_CODE (parm) != PARM_DECL
  3992.       || DECL_ARG_TYPE (parm) == NULL)
  3993.     {
  3994.       DECL_RTL (parm) = gen_rtx (MEM, BLKmode, const0_rtx);
  3995.       TREE_USED (parm) = 1;
  3996.       continue;
  3997.     }
  3998.  
  3999.       /* Find mode of arg as it is passed, and mode of arg
  4000.      as it should be during execution of this function.  */
  4001.       passed_mode = TYPE_MODE (DECL_ARG_TYPE (parm));
  4002.       nominal_mode = TYPE_MODE (TREE_TYPE (parm));
  4003.  
  4004.       /* Get this parm's offset as an rtx.  */
  4005.       stack_offset = stack_args_size;
  4006.       stack_offset.constant += first_parm_offset;
  4007.  
  4008.       /* If this argument needs more than the usual parm alignment, do
  4009.      extrinsic padding to reach that alignment.  */
  4010.  
  4011. #ifdef MAX_PARM_BOUNDARY
  4012.       /* If MAX_PARM_BOUNDARY is not defined, it means that the usual
  4013.      alignment requirements are relaxed for parms, and that no parm
  4014.      needs more alignment than PARM_BOUNDARY, regardless of data type.  */
  4015.  
  4016.       if (PARM_BOUNDARY < TYPE_ALIGN (DECL_ARG_TYPE (parm)))
  4017.     {
  4018.       int boundary = PARM_BOUNDARY;
  4019.  
  4020.       /* Determine the boundary to pad up to.  */
  4021.       if (TYPE_ALIGN (DECL_ARG_TYPE (parm)) > boundary)
  4022.         boundary = TYPE_ALIGN (DECL_ARG_TYPE (parm));
  4023.       if (boundary > MAX_PARM_BOUNDARY)
  4024.         boundary = MAX_PARM_BOUNDARY;
  4025.  
  4026.       /* If the previous args don't reach such a boundary,
  4027.          advance to the next one.  */
  4028.       boundary /= BITS_PER_UNIT;
  4029.       stack_offset.constant += boundary - 1;
  4030.       stack_offset.constant &= ~(boundary - 1);
  4031.       stack_args_size.constant += boundary - 1;
  4032.       stack_args_size.constant &= ~(boundary - 1);
  4033.  
  4034.       if (stack_offset.var != 0)
  4035.         abort ();        /* This case not implemented yet */
  4036.     }
  4037. #endif /* MAX_PARM_BOUNDARY */
  4038.  
  4039.       /* Find out if the parm needs intrinsic padding (up to PARM_BOUNDARY),
  4040.      and whether above or below.  */
  4041.  
  4042.       where_pad
  4043.     = FUNCTION_ARG_PADDING (passed_mode,
  4044.                 expand_expr (size_in_bytes (DECL_ARG_TYPE (parm)),
  4045.                          0, VOIDmode, 0));
  4046.  
  4047.       /* If arg should be padded below, adjust the stack address upward.
  4048.      This padding is considered part of the space occupied by the
  4049.      argument.  It pads only up to PARM_BOUNDARY, and it does not
  4050.      depend on the previous arguments, since they are assumed to
  4051.      occupy a multiple of PARM_BOUNDARY.  */
  4052.  
  4053.       if (where_pad == downward)
  4054.     {
  4055.       if (passed_mode != BLKmode)
  4056.         {
  4057.           if (GET_MODE_BITSIZE (passed_mode) % PARM_BOUNDARY)
  4058.         stack_offset.constant
  4059.           += (((GET_MODE_BITSIZE (passed_mode) + PARM_BOUNDARY - 1)
  4060.                / PARM_BOUNDARY * PARM_BOUNDARY / BITS_PER_UNIT)
  4061.               - GET_MODE_SIZE (passed_mode));
  4062.         }
  4063.       else
  4064.         {
  4065.           tree sizetree = size_in_bytes (DECL_ARG_TYPE (parm));
  4066.           if (TREE_INT_CST_LOW (sizetree) * BITS_PER_UNIT != PARM_BOUNDARY)
  4067.         {
  4068.           /* Round the size up to multiple of PARM_BOUNDARY bits.  */
  4069.           tree s1 = convert_units (sizetree, BITS_PER_UNIT, PARM_BOUNDARY);
  4070.           tree s2 = convert_units (s1, PARM_BOUNDARY, BITS_PER_UNIT);
  4071.           /* Add it in.  */
  4072.           ADD_PARM_SIZE (stack_offset, s2);
  4073.           SUB_PARM_SIZE (stack_offset, sizetree);
  4074.           extra = stack_offset.constant % UNITS_PER_WORD;
  4075.           stack_offset.constant -= extra;
  4076.         }
  4077.         }
  4078.     }
  4079.  
  4080.       stack_offset_rtx = ARGS_SIZE_RTX (stack_offset);
  4081.  
  4082.       /* Determine parm's home in the stack,
  4083.      in case it arrives in the stack or we should pretend it did.  */
  4084.       stack_parm
  4085.     = gen_rtx (MEM, passed_mode,
  4086.            memory_address (passed_mode,
  4087.                    gen_rtx (PLUS, Pmode,
  4088.                         internal_arg_pointer,
  4089.                         stack_offset_rtx)));
  4090.  
  4091.       /* If this is a memory ref that contains aggregate components,
  4092.      mark it as such for cse and loop optimize.  */
  4093.       MEM_IN_STRUCT_P (stack_parm) = aggregate;
  4094.  
  4095.       /* Let machine desc say which reg (if any) the parm arrives in.
  4096.      0 means it arrives on the stack.  */
  4097.       entry_parm = 0;
  4098.       /* Variable-size args, and args following such, are never in regs.  */
  4099.       if (TREE_CODE (TYPE_SIZE (TREE_TYPE (parm))) == INTEGER_CST
  4100.       || stack_offset.var != 0)
  4101.     {
  4102.       /* Set LAST_NAMED if this is last named arg before some
  4103.          anonymous args.  We treat it as if it were anonymous too.  */
  4104.       int last_named = (TREE_CHAIN (parm) == 0 && vararg);
  4105. #ifdef FUNCTION_INCOMING_ARG
  4106.       entry_parm
  4107.         = FUNCTION_INCOMING_ARG (args_so_far, passed_mode,
  4108.                      DECL_ARG_TYPE (parm), ! last_named);
  4109. #else
  4110.       entry_parm
  4111.         = FUNCTION_ARG (args_so_far, passed_mode, DECL_ARG_TYPE (parm),
  4112.                 ! last_named);
  4113. #endif
  4114.     }
  4115.  
  4116.       /* If this parm was passed part in regs and part in memory,
  4117.      pretend it arrived entirely in memory
  4118.      by pushing the register-part onto the stack.
  4119.  
  4120.      In the special case of a DImode or DFmode that is split,
  4121.      we could put it together in a pseudoreg directly,
  4122.      but for now that's not worth bothering with.  */
  4123.  
  4124.       if (entry_parm)
  4125.     {
  4126.       int nregs = 0;
  4127.       int i;
  4128. #ifdef FUNCTION_ARG_PARTIAL_NREGS
  4129.       nregs = FUNCTION_ARG_PARTIAL_NREGS (args_so_far, passed_mode,
  4130.                           DECL_ARG_TYPE (parm), 1);
  4131. #endif
  4132.  
  4133. #if 0 /* Replaced by new calling convention
  4134.      which actually passes these args on the stack.  */
  4135.       /* If this is the last named arg and anonymous args follow,
  4136.          likewise pretend this arg arrived on the stack
  4137.          so varargs can find the anonymous args following it.  */
  4138.       if (TREE_CHAIN (parm) == 0 && vararg)
  4139.         {
  4140.           if (GET_MODE (entry_parm) == BLKmode)
  4141.         nregs = GET_MODE_SIZE (GET_MODE (entry_parm)) / UNITS_PER_WORD;
  4142.           else
  4143.         nregs = (int_size_in_bytes (DECL_ARG_TYPE (parm))
  4144.              / UNITS_PER_WORD);
  4145.         }
  4146. #endif /* 0 */
  4147.  
  4148.       if (nregs > 0)
  4149.         {
  4150.           current_function_pretend_args_size
  4151.         = (((nregs * UNITS_PER_WORD) + (PARM_BOUNDARY / BITS_PER_UNIT) - 1)
  4152.            / (PARM_BOUNDARY / BITS_PER_UNIT)
  4153.            * (PARM_BOUNDARY / BITS_PER_UNIT));
  4154.  
  4155.           i = nregs;
  4156.           while (--i >= 0)
  4157.         emit_move_insn (gen_rtx (MEM, SImode,
  4158.                      plus_constant (XEXP (stack_parm, 0),
  4159.                             i * GET_MODE_SIZE (SImode))),
  4160.                 gen_rtx (REG, SImode, REGNO (entry_parm) + i));
  4161.           entry_parm = stack_parm;
  4162.         }
  4163.     }
  4164.  
  4165.       /* If we didn't decide this parm came in a register,
  4166.      by default it came on the stack.  */
  4167.       if (entry_parm == 0)
  4168.     entry_parm = stack_parm;
  4169.  
  4170.       /* For a stack parm, record in DECL_OFFSET the arglist offset
  4171.      of the parm at the time it is passed (before conversion).  */
  4172.       if (entry_parm == stack_parm)
  4173.     DECL_OFFSET (parm) = stack_offset.constant * BITS_PER_UNIT;
  4174.  
  4175.       /* If there is actually space on the stack for this parm,
  4176.      count it in stack_args_size; otherwise set stack_parm to 0
  4177.      to indicate there is no preallocated stack slot for the parm.  */
  4178.  
  4179.       if (entry_parm == stack_parm
  4180. #ifdef REG_PARM_STACK_SPACE
  4181.       /* On some machines, even if a parm value arrives in a register
  4182.          there is still an (uninitialized) stack slot allocated for it.  */
  4183.       || 1
  4184. #endif
  4185.       )
  4186.     {
  4187.       tree sizetree = size_in_bytes (DECL_ARG_TYPE (parm));
  4188.       if (where_pad != none
  4189.           && TREE_INT_CST_LOW (sizetree) * BITS_PER_UNIT != PARM_BOUNDARY)
  4190.         {
  4191.           /* Round the size up to multiple of PARM_BOUNDARY bits.  */
  4192.           tree s1 = convert_units (sizetree, BITS_PER_UNIT, PARM_BOUNDARY);
  4193.           sizetree = convert_units (s1, PARM_BOUNDARY, BITS_PER_UNIT);
  4194.         }
  4195.       /* Add it in.  */
  4196.       ADD_PARM_SIZE (stack_args_size, sizetree);
  4197.     }
  4198.       else
  4199.     /* No stack slot was pushed for this parm.  */
  4200.     stack_parm = 0;
  4201.  
  4202.       /* Now adjust STACK_PARM to the mode and precise location
  4203.      where this parameter should live during execution,
  4204.      if we discover that it must live in the stack during execution.
  4205.      To make debuggers happier on big-endian machines, we store
  4206.      the value in the last bytes of the space available.  */
  4207.  
  4208.       if (nominal_mode != BLKmode && nominal_mode != passed_mode
  4209.       && stack_parm != 0)
  4210.     {
  4211. #ifdef BYTES_BIG_ENDIAN
  4212.       if (GET_MODE_SIZE (nominal_mode) < UNITS_PER_WORD)
  4213.         {
  4214.           stack_offset.constant
  4215.         += GET_MODE_SIZE (passed_mode)
  4216.           - GET_MODE_SIZE (nominal_mode);
  4217.           stack_offset_rtx = ARGS_SIZE_RTX (stack_offset);
  4218.         }
  4219. #endif
  4220.  
  4221.       stack_parm
  4222.         = gen_rtx (MEM, nominal_mode,
  4223.                memory_address (nominal_mode,
  4224.                        gen_rtx (PLUS, Pmode,
  4225.                         arg_pointer_rtx,
  4226.                         stack_offset_rtx)));
  4227.  
  4228.       /* If this is a memory ref that contains aggregate components,
  4229.          mark it as such for cse and loop optimize.  */
  4230.       MEM_IN_STRUCT_P (stack_parm) = aggregate;
  4231.     }
  4232.  
  4233.       /* If there is rounding to do for a BLKmode parameter,
  4234.      add it in here, since STACK_OFFSET is not used for the
  4235.      rest of this iteration.  */
  4236.       stack_offset.constant += extra;
  4237.  
  4238.       /* ENTRY_PARM is an RTX for the parameter as it arrives,
  4239.      in the mode in which it arrives.
  4240.      STACK_PARM is an RTX for a stack slot where the parameter can live
  4241.      during the function (in case we want to put it there).
  4242.      STACK_PARM is 0 if no stack slot was pushed for it.
  4243.  
  4244.      Now output code if necessary to convert ENTRY_PARM to
  4245.      the type in which this function declares it,
  4246.      and store that result in an appropriate place,
  4247.      which may be a pseudo reg, may be STACK_PARM,
  4248.      or may be a local stack slot if STACK_PARM is 0.
  4249.  
  4250.      Set DECL_RTL to that place.  */
  4251.  
  4252.       if (nominal_mode == BLKmode)
  4253.     {
  4254.       /* If a BLKmode arrives in registers, copy it to a stack slot.  */
  4255.       if (GET_CODE (entry_parm) == REG)
  4256.         {
  4257.           if (stack_parm == 0)
  4258.         stack_parm
  4259.           = assign_stack_local (GET_MODE (entry_parm),
  4260.                     int_size_in_bytes (TREE_TYPE (parm)));
  4261.  
  4262.           move_block_from_reg (REGNO (entry_parm), stack_parm,
  4263.                    ((int_size_in_bytes (TREE_TYPE (parm))
  4264.                      + UNITS_PER_WORD - 1)
  4265.                     / UNITS_PER_WORD));
  4266.         }
  4267.       else if (vararg)
  4268.         {
  4269.           /* If this function uses varargs, and `__builtin_saveregs'
  4270.          can clobber this stack location, then protect it.  */
  4271.           rtx pseudo_parm;
  4272. #ifdef FUNCTION_INCOMING_ARG
  4273.           pseudo_parm
  4274.         = FUNCTION_INCOMING_ARG (args_so_far, SImode,
  4275.                      integer_type_node, 1);
  4276. #else
  4277.           pseudo_parm
  4278.         = FUNCTION_ARG (args_so_far, SImode,
  4279.                 integer_type_node, 1);
  4280. #endif
  4281.           if (pseudo_parm && GET_CODE (pseudo_parm) == REG)
  4282.         {
  4283.           push_to_sequence (save_from_saveregs);
  4284.           move_block_to_reg (REGNO (pseudo_parm), stack_parm,
  4285.                      int_size_in_bytes (TREE_TYPE (parm))
  4286.                      / UNITS_PER_WORD);
  4287.           save_from_saveregs = get_insns ();
  4288.           end_sequence (0);
  4289.         }
  4290.         }
  4291.       DECL_RTL (parm) = stack_parm;
  4292.     }
  4293.       else if (! ((obey_regdecls && ! TREE_REGDECL (parm)
  4294.            && ! TREE_INLINE (fndecl))
  4295.           /* layout_decl may set this.  */
  4296.           || TREE_ADDRESSABLE (parm)
  4297.           || TREE_VOLATILE (parm)
  4298.           /* If -ffloat-store specified, don't put explicit
  4299.              float variables into registers.  */
  4300.           || (flag_float_store
  4301.               && TREE_CODE (TREE_TYPE (parm)) == REAL_TYPE)))
  4302.     {
  4303.       /* Store the parm in a pseudoregister during the function.  */
  4304.       register rtx parmreg = gen_reg_rtx (nominal_mode);
  4305.  
  4306.       REG_USERVAR_P (parmreg) = 1;
  4307.       DECL_RTL (parm) = parmreg;
  4308.  
  4309.       /* Copy the value into the register.  */
  4310.       if (GET_MODE (parmreg) != GET_MODE (entry_parm))
  4311.         convert_move (parmreg, validize_mem (entry_parm), 0);
  4312.       else
  4313.         emit_move_insn (parmreg, validize_mem (entry_parm));
  4314.  
  4315.       /* In any case, record the parm's desired stack location
  4316.          in case we later discover it must live in the stack.  */
  4317.       if (REGNO (parmreg) >= nparmregs)
  4318.         {
  4319.           rtx *new;
  4320.           nparmregs = REGNO (parmreg) + 5;
  4321.           new = (rtx *) oballoc (nparmregs * sizeof (rtx));
  4322.           bcopy (parm_reg_stack_loc, new, nparmregs * sizeof (rtx));
  4323.           parm_reg_stack_loc = new;
  4324.         }
  4325.       parm_reg_stack_loc[REGNO (parmreg)] = stack_parm;
  4326.  
  4327.       /* Mark the register as eliminable if we did no conversion
  4328.          and it was copied from memory at a fixed offset,
  4329.          and the arg pointer was not copied to a pseudo-reg.
  4330.          If the arg pointer is a pseudo reg, such memory-equivalences
  4331.          as we make here would screw up life analysis for it.  */
  4332.       if (nominal_mode == passed_mode
  4333.           && GET_CODE (entry_parm) == MEM
  4334.           && stack_offset.var == 0
  4335.           && ! arg_pointer_copied)
  4336.         REG_NOTES (get_last_insn ())
  4337.           = gen_rtx (EXPR_LIST, REG_EQUIV,
  4338.              entry_parm, REG_NOTES (get_last_insn ()));
  4339.  
  4340.       /* For pointer data type, suggest pointer register.  */
  4341.       if (TREE_CODE (TREE_TYPE (parm)) == POINTER_TYPE)
  4342.         mark_reg_pointer (parmreg);
  4343.     }
  4344.       else
  4345.     {
  4346.       /* Value must be stored in the stack slot STACK_PARM
  4347.          during function execution.  */
  4348.  
  4349.       if (passed_mode != nominal_mode)
  4350.         /* Conversion is required.  */
  4351.         entry_parm = convert_to_mode (nominal_mode, entry_parm, 0);
  4352.  
  4353.       if (entry_parm != stack_parm)
  4354.         {
  4355.           if (stack_parm == 0)
  4356.         stack_parm = assign_stack_local (GET_MODE (entry_parm),
  4357.                          GET_MODE_SIZE (GET_MODE (entry_parm)));
  4358.           emit_move_insn (validize_mem (stack_parm),
  4359.                   validize_mem (entry_parm));
  4360.         }
  4361.  
  4362.       DECL_RTL (parm) = stack_parm;
  4363.       frame_pointer_needed = 1;
  4364.     }
  4365.       
  4366.       if (TREE_VOLATILE (parm))
  4367.     MEM_VOLATILE_P (DECL_RTL (parm)) = 1;
  4368.       if (TREE_READONLY (parm))
  4369.     RTX_UNCHANGING_P (DECL_RTL (parm)) = 1;
  4370.  
  4371.       /* Update info on where next arg arrives in registers.  */
  4372.  
  4373.       FUNCTION_ARG_ADVANCE (args_so_far, passed_mode, DECL_ARG_TYPE (parm), 1);
  4374.     }
  4375.  
  4376.   max_parm_reg = max_reg_num ();
  4377.   last_parm_insn = get_last_insn ();
  4378.  
  4379.   current_function_args_size = stack_args_size.constant;
  4380. }
  4381.  
  4382. /* Allocation of space for returned structure values.
  4383.    During the rtl generation pass, `get_structure_value_addr'
  4384.    is called from time to time to request the address of a block in our
  4385.    stack frame in which called functions will store the structures
  4386.    they are returning.  The same space is used for all of these blocks.  
  4387.  
  4388.    We allocate these blocks like stack locals.  We keep reusing
  4389.    the same block until a bigger one is needed.  */
  4390.  
  4391. /* Length in bytes of largest structure value returned by
  4392.    any function called so far in this function.  */
  4393. static int max_structure_value_size;
  4394.  
  4395. /* An rtx for the addr we are currently using for structure values.
  4396.    This is typically (PLUS (REG:SI stackptr) (CONST_INT...)).  */
  4397. static rtx structure_value;
  4398.  
  4399. rtx
  4400. get_structure_value_addr (sizex)
  4401.      rtx sizex;
  4402. {
  4403.   register int size;
  4404.   if (GET_CODE (sizex) != CONST_INT)
  4405.     abort ();
  4406.   size = INTVAL (sizex);
  4407.  
  4408.   /* Round up to a multiple of the main allocation unit.  */
  4409.   size = (((size + (BIGGEST_ALIGNMENT / BITS_PER_UNIT) - 1)
  4410.        / (BIGGEST_ALIGNMENT / BITS_PER_UNIT))
  4411.       * (BIGGEST_ALIGNMENT / BITS_PER_UNIT));
  4412.  
  4413.   /* If this size is bigger than space we know to use,
  4414.      get a bigger piece of space.  */
  4415.   if (size > max_structure_value_size)
  4416.     {
  4417.       max_structure_value_size = size;
  4418.       structure_value = assign_stack_local (BLKmode, size);
  4419.       if (GET_CODE (structure_value) == MEM)
  4420.     structure_value = XEXP (structure_value, 0);
  4421.     }
  4422.  
  4423.   return structure_value;
  4424. }
  4425.  
  4426. /* Walk the tree of LET_STMTs describing the binding levels within a function
  4427.    and warn about uninitialized variables.
  4428.    This is done after calling flow_analysis and before global_alloc
  4429.    clobbers the pseudo-regs to hard regs.  */
  4430.  
  4431. void
  4432. uninitialized_vars_warning (block)
  4433.      tree block;
  4434. {
  4435.   register tree decl, sub;
  4436.   for (decl = STMT_VARS (block); decl; decl = TREE_CHAIN (decl))
  4437.     {
  4438.       if (TREE_CODE (decl) == VAR_DECL
  4439.       /* These warnings are unreliable for and aggregates
  4440.          because assigning the fields one by one can fail to convince
  4441.          flow.c that the entire aggregate was initialized.
  4442.          Unions are troublesome because members may be shorter.  */
  4443.       && TREE_CODE (TREE_TYPE (decl)) != RECORD_TYPE
  4444.       && TREE_CODE (TREE_TYPE (decl)) != UNION_TYPE
  4445.       && TREE_CODE (TREE_TYPE (decl)) != ARRAY_TYPE
  4446.       && DECL_RTL (decl) != 0
  4447.       && GET_CODE (DECL_RTL (decl)) == REG
  4448.       && regno_uninitialized (REGNO (DECL_RTL (decl))))
  4449.     warning_with_decl (decl,
  4450.                "`%s' may be used uninitialized in this function");
  4451.       if (TREE_CODE (decl) == VAR_DECL
  4452.       && DECL_RTL (decl) != 0
  4453.       && GET_CODE (DECL_RTL (decl)) == REG
  4454.       && regno_clobbered_at_setjmp (REGNO (DECL_RTL (decl))))
  4455.     warning_with_decl (decl,
  4456.                "variable `%s' may be clobbered by `longjmp'");
  4457.     }
  4458.   for (sub = STMT_SUBBLOCKS (block); sub; sub = TREE_CHAIN (sub))
  4459.     uninitialized_vars_warning (sub);
  4460. }
  4461.  
  4462. /* If this function call setjmp, put all vars into the stack
  4463.    unless they were declared `register'.  */
  4464.  
  4465. void
  4466. setjmp_protect (block)
  4467.      tree block;
  4468. {
  4469.   register tree decl, sub;
  4470.   for (decl = STMT_VARS (block); decl; decl = TREE_CHAIN (decl))
  4471.     if ((TREE_CODE (decl) == VAR_DECL
  4472.      || TREE_CODE (decl) == PARM_DECL)
  4473.     && DECL_RTL (decl) != 0
  4474.     && GET_CODE (DECL_RTL (decl)) == REG
  4475.     && ! TREE_REGDECL (decl))
  4476.       put_var_into_stack (decl);
  4477.   for (sub = STMT_SUBBLOCKS (block); sub; sub = TREE_CHAIN (sub))
  4478.     setjmp_protect (sub);
  4479. }
  4480.  
  4481. /* Generate RTL for the start of the function SUBR (a FUNCTION_DECL tree node)
  4482.    and initialize static variables for generating RTL for the statements
  4483.    of the function.  */
  4484.  
  4485. void
  4486. init_function_start (subr)
  4487.      tree subr;
  4488. {
  4489.   this_function = subr;
  4490.   cse_not_expected = ! optimize;
  4491.  
  4492.   /* We have not yet found a reason why a frame pointer cannot
  4493.      be omitted for this function in particular, but maybe we know
  4494.      a priori that it is required.
  4495.      `flag_omit_frame_pointer' has its main effect here.  */
  4496.   frame_pointer_needed = FRAME_POINTER_REQUIRED || ! flag_omit_frame_pointer;
  4497.  
  4498.   /* Caller save not needed yet.  */
  4499.   caller_save_needed = 0;
  4500.  
  4501.   /* No gotos have been expanded yet.  */
  4502.   goto_fixup_chain = 0;
  4503.  
  4504.   /* No stack slots have been made yet.  */
  4505.   stack_slot_list = 0;
  4506.  
  4507.   /* No invalid stack slots have been made yet.  */
  4508.   invalid_stack_slot = 0;
  4509.  
  4510.   /* No parm regs have been allocated.
  4511.      (This is important for output_inline_function.)  */
  4512.   max_parm_reg = FIRST_PSEUDO_REGISTER;
  4513.  
  4514.   /* Initialize the RTL mechanism.  */
  4515.   init_emit (write_symbols);
  4516.  
  4517.   /* Initialize the queue of pending postincrement and postdecrements,
  4518.      and some other info in expr.c.  */
  4519.   init_expr ();
  4520.  
  4521.   init_const_rtx_hash_table ();
  4522.  
  4523.   /* Decide whether function should try to pop its args on return.  */
  4524.  
  4525.   current_function_pops_args = RETURN_POPS_ARGS (TREE_TYPE (subr));
  4526.  
  4527.   current_function_name = (char *)lang_printable_name (subr);
  4528.  
  4529.   /* Nonzero if this is a nested function that uses a static chain.  */
  4530.  
  4531.   current_function_needs_context
  4532.     = (DECL_CONTEXT (current_function_decl) != 0
  4533.        && TREE_CODE (DECL_CONTEXT (current_function_decl)) == LET_STMT);
  4534.  
  4535.   /* Set if a call to setjmp is seen.  */
  4536.  
  4537.   current_function_calls_setjmp = 0;
  4538.   current_function_calls_alloca = 0;
  4539.  
  4540.   current_function_returns_pcc_struct = 0;
  4541.   current_function_returns_struct = 0;
  4542.  
  4543.   /* No space assigned yet for structure values.  */
  4544.   max_structure_value_size = 0;
  4545.   structure_value = 0;
  4546.  
  4547.   /* We are not currently within any block, conditional, loop or case.
  4548.      @@ No longer true.  We are within the block for the parms.  */
  4549.   block_stack = 0;
  4550.   loop_stack = 0;
  4551.   case_stack = 0;
  4552.   cond_stack = 0;
  4553.   nesting_stack = 0;
  4554.   nesting_depth = 0;
  4555.  
  4556.   /* We have not yet needed to make a label to jump to for tail-recursion.  */
  4557.   tail_recursion_label = 0;
  4558.  
  4559.   /* No stack slots allocated yet.  */
  4560.   frame_offset = STARTING_FRAME_OFFSET;
  4561.  
  4562.   /* No SAVE_EXPRs in this function yet.  */
  4563.   save_expr_regs = 0;
  4564.  
  4565.   /* No parameters to protect from `__builtin_saveregs' yet.  */
  4566.   save_from_saveregs = 0;
  4567.  
  4568.   /* No RTL_EXPRs in this function yet.  */
  4569.   rtl_expr_chain = 0;
  4570.  
  4571.   /* Within function body, compute a type's size as soon it is laid out.  */
  4572.   immediate_size_expand++;
  4573.  
  4574.   init_pending_stack_adjust ();
  4575.   inhibit_defer_pop = 0;
  4576.   current_function_pretend_args_size = 0;
  4577.  
  4578.   /* Prevent ever trying to delete the first instruction of a function.
  4579.      Also tell final how to output a linenum before the function prologue.  */
  4580.   emit_line_note (DECL_SOURCE_FILE (subr), DECL_SOURCE_LINE (subr));
  4581.   /* Make sure first insn is a note even if we don't want linenums.
  4582.      This makes sure the first insn will never be deleted.
  4583.      Also, final expects a note to appear there.  */
  4584.   emit_note (0, NOTE_INSN_DELETED);
  4585.   /* Indicate the beginning of the function body,
  4586.      as opposed to parm setup.  */
  4587.   emit_note (0, NOTE_INSN_FUNCTION_BEG);
  4588.  
  4589.   /* Set flags used by final.c.  */
  4590.   if (aggregate_value_p (DECL_RESULT (subr)))
  4591.     {
  4592. #ifdef PCC_STATIC_STRUCT_RETURN
  4593.       if (flag_pcc_struct_return)
  4594.     current_function_returns_pcc_struct = 1;
  4595.       else
  4596. #endif
  4597.     current_function_returns_struct = 1;
  4598.     }
  4599. }
  4600.  
  4601. /* Start the RTL for a new function, and set variables used for
  4602.    emitting RTL.
  4603.    SUBR is the FUNCTION_DECL node.
  4604.    PARMS_HAVE_CLEANUPS is nonzero if there are cleanups associated with
  4605.    the function's parameters, which must be run at any return statement.  */
  4606.  
  4607. void
  4608. expand_function_start (subr, parms_have_cleanups)
  4609.      tree subr;
  4610.      int parms_have_cleanups;
  4611. {
  4612.   register int i;
  4613.   tree tem;
  4614.  
  4615.   /* Make sure volatile mem refs aren't considered
  4616.      valid operands of arithmetic insns.  */
  4617.   init_recog ();
  4618.  
  4619.   /* If the parameters of this function need cleaning up, get a label
  4620.      for the beginning of the code which executes those cleanups.  This must
  4621.      be done before doing anything with return_label.  */
  4622.   if (parms_have_cleanups)
  4623.     cleanup_label = gen_label_rtx ();
  4624.   else
  4625.     cleanup_label = 0;
  4626.  
  4627.   /* Make the label for return statements to jump to, if this machine
  4628.      does not have a one-instruction return and uses an epilogue,
  4629.      or if it returns a structure, or if it has parm cleanups.  */
  4630. #ifdef HAVE_return
  4631.   if (cleanup_label == 0 && HAVE_return
  4632.       && ! current_function_returns_pcc_struct
  4633.       && ! (current_function_returns_struct && ! optimize))
  4634.     return_label = 0;
  4635.   else
  4636.     return_label = gen_label_rtx ();
  4637. #else
  4638.   return_label = gen_label_rtx ();
  4639. #endif
  4640.  
  4641.   /* Initialize rtx used to return the value.  */
  4642.   /* Do this before assign_parms so that we copy the struct value address
  4643.      before any library calls that assign parms might generate.  */
  4644.  
  4645.   /* Decide whether to return the value in memory or in a register.  */
  4646.   if (aggregate_value_p (DECL_RESULT (subr)))
  4647.     {
  4648.       /* Returning something that won't go in a register.  */
  4649.       register rtx value_address;
  4650.  
  4651. #ifdef PCC_STATIC_STRUCT_RETURN
  4652.       if (flag_pcc_struct_return)
  4653.     {
  4654.       int size = int_size_in_bytes (TREE_TYPE (DECL_RESULT (subr)));
  4655.       value_address = assemble_static_space (size);
  4656.       current_function_returns_pcc_struct = 1;
  4657.     }
  4658.       else
  4659. #endif
  4660.     {
  4661.       /* Expect to be passed the address of a place to store the value.  */
  4662.       value_address = gen_reg_rtx (Pmode);
  4663.       emit_move_insn (value_address, struct_value_incoming_rtx);
  4664.       current_function_returns_struct = 1;
  4665.     }
  4666.       DECL_RTL (DECL_RESULT (subr))
  4667.     = gen_rtx (MEM, DECL_MODE (DECL_RESULT (subr)),
  4668.            value_address);
  4669.     }
  4670.   else if (DECL_MODE (DECL_RESULT (subr)) == VOIDmode)
  4671.     /* If return mode is void, this decl rtl should not be used.  */
  4672.     DECL_RTL (DECL_RESULT (subr)) = 0;
  4673.   else if (parms_have_cleanups)
  4674.     {
  4675.       /* If function will end with cleanup code for parms,
  4676.      compute the return values into a pseudo reg,
  4677.      which we will copy into the true return register
  4678.      after the cleanups are done.  */
  4679.       DECL_RTL (DECL_RESULT (subr))
  4680.     = gen_reg_rtx (DECL_MODE (DECL_RESULT (subr)));
  4681.       TREE_REGDECL (DECL_RESULT (subr)) = 1;
  4682.     }
  4683.   else
  4684.     /* Scalar, returned in a register.  */
  4685.     {
  4686. #ifdef FUNCTION_OUTGOING_VALUE
  4687.       DECL_RTL (DECL_RESULT (subr))
  4688.     = FUNCTION_OUTGOING_VALUE (TREE_TYPE (DECL_RESULT (subr)), subr);
  4689. #else
  4690.       DECL_RTL (DECL_RESULT (subr))
  4691.     = FUNCTION_VALUE (TREE_TYPE (DECL_RESULT (subr)), subr);
  4692. #endif
  4693.  
  4694.       current_function_returns_pointer 
  4695.     = (TREE_CODE (DECL_RESULT_TYPE (subr)) == POINTER_TYPE);
  4696.  
  4697.       /* Mark this reg as the function's return value.  */
  4698.       if (GET_CODE (DECL_RTL (DECL_RESULT (subr))) == REG)
  4699.     {
  4700.       REG_FUNCTION_VALUE_P (DECL_RTL (DECL_RESULT (subr))) = 1;
  4701.       TREE_REGDECL (DECL_RESULT (subr)) = 1;
  4702.     }
  4703.     }
  4704.  
  4705.   /* Initialize rtx for parameters and local variables.
  4706.      In some cases this requires emitting insns.  */
  4707.  
  4708.   assign_parms (subr);
  4709.  
  4710.   /* If doing stupid allocation, mark parms as born here.  */
  4711.  
  4712.   if (GET_CODE (get_last_insn ()) != NOTE)
  4713.     emit_note (0, NOTE_INSN_DELETED);
  4714.   parm_birth_insn = get_last_insn ();
  4715.  
  4716.   if (obey_regdecls)
  4717.     {
  4718.       for (i = FIRST_PSEUDO_REGISTER; i < max_parm_reg; i++)
  4719.     use_variable (regno_reg_rtx[i]);
  4720.     }
  4721.  
  4722.   /* After the parm initializations is where the tail-recursion label
  4723.      should go, if we end up needing one.  */
  4724.   tail_recursion_reentry = get_last_insn ();
  4725.  
  4726.   /* Evaluate now the sizes of any types declared among the arguments.  */
  4727.   for (tem = get_pending_sizes (); tem; tem = TREE_CHAIN (tem))
  4728.     expand_expr (TREE_VALUE (tem), 0, VOIDmode, 0);
  4729.  
  4730.   /* Make sure there is a line number after the function entry setup code.
  4731.      There normally is one anyway, from the following statement,
  4732.      but there could fail to be one if there is no newline here.  */
  4733.   force_next_line_note ();
  4734. }
  4735.  
  4736. /* Generate RTL for the end of the current function.
  4737.    FILENAME and LINE are the current position in the source file.  */
  4738.  
  4739. /* ??? Nobody seems to emit the cleanup_label and the cleanups themselves.
  4740.  
  4741.    !!! Not true.  finish_function does this is cplus-decl.c.  */
  4742.  
  4743. void
  4744. expand_function_end (filename, line)
  4745.      char *filename;
  4746.      int line;
  4747. {
  4748.   register int i;
  4749.   tree decl;
  4750.   extern rtx sequence_stack;
  4751.  
  4752. #if 0  /* I think unused parms are legitimate enough.  */
  4753.   /* Warn about unused parms.  */
  4754.   if (warn_unused)
  4755.     for (decl = DECL_ARGUMENTS (current_function_decl);
  4756.      decl; decl = TREE_CHAIN (decl))
  4757.       if (! TREE_USED (decl) && TREE_CODE (decl) == VAR_DECL)
  4758.     warning_with_decl (decl, "unused parameter `%s'");
  4759. #endif
  4760.  
  4761.   /* End any sequences that failed to be closed due to syntax errors.  */
  4762.   while (sequence_stack)
  4763.     end_sequence (0);
  4764.  
  4765.   /* Outside function body, can't compute type's actual size
  4766.      until next function's body starts.  */
  4767.   immediate_size_expand--;
  4768.  
  4769.   /* If doing stupid register allocation,
  4770.      mark register parms as dying here.  */
  4771.  
  4772.   if (obey_regdecls)
  4773.     {
  4774.       rtx tem;
  4775.       for (i = FIRST_PSEUDO_REGISTER; i < max_parm_reg; i++)
  4776.     use_variable (regno_reg_rtx[i]);
  4777.  
  4778.       /* Likewise for the regs of all the SAVE_EXPRs in the function.  */
  4779.  
  4780.       for (tem = save_expr_regs; tem; tem = XEXP (tem, 1))
  4781.     {
  4782.       use_variable (XEXP (tem, 0));
  4783.       use_variable_after (XEXP (tem, 0), parm_birth_insn);
  4784.     }
  4785.     }
  4786.  
  4787.   clear_pending_stack_adjust ();
  4788.   do_pending_stack_adjust ();
  4789.  
  4790.   /* Mark the end of the function body.
  4791.      If control reaches this insn, the function can drop through
  4792.      without returning a value.  */
  4793.   emit_note (0, NOTE_INSN_FUNCTION_END);
  4794.  
  4795.   /* Output a linenumber for the end of the function.
  4796.      SDB depends on this.  */
  4797.   emit_line_note_force (filename, line);
  4798.  
  4799.   /* Output the label for the actual return from the function,
  4800.      if one is expected.  This happens either because a function epilogue
  4801.      is used instead of a return instruction, or because a return was done
  4802.      with a goto in order to run local cleanups, or because of pcc-style
  4803.      structure returning.  */
  4804.  
  4805.   if (return_label)
  4806.     emit_label (return_label);
  4807.  
  4808.   /* If we had calls to alloca, and this machine needs
  4809.      an accurate stack pointer to exit the function,
  4810.      insert some code to save and restore the stack pointer.  */
  4811. #ifdef EXIT_IGNORE_STACK
  4812.   if (! EXIT_IGNORE_STACK)
  4813. #endif
  4814.     if (current_function_calls_alloca)
  4815.       {
  4816.     rtx tem = gen_reg_rtx (Pmode);
  4817.     emit_insn_after (gen_rtx (SET, VOIDmode, tem, stack_pointer_rtx),
  4818.              parm_birth_insn);
  4819.     emit_insn (gen_rtx (SET, VOIDmode, stack_pointer_rtx, tem));
  4820.       }
  4821.  
  4822.   /* If scalar return value was computed in a pseudo-reg,
  4823.      copy that to the hard return register.  */
  4824.   if (DECL_RTL (DECL_RESULT (current_function_decl)) != 0
  4825.       && GET_CODE (DECL_RTL (DECL_RESULT (current_function_decl))) == REG
  4826.       && (REGNO (DECL_RTL (DECL_RESULT (current_function_decl)))
  4827.       >= FIRST_PSEUDO_REGISTER))
  4828.     {
  4829.       rtx real_decl_result;
  4830.  
  4831. #ifdef FUNCTION_OUTGOING_VALUE
  4832.       real_decl_result
  4833.     = FUNCTION_OUTGOING_VALUE (TREE_TYPE (DECL_RESULT (current_function_decl)),
  4834.                    current_function_decl);
  4835. #else
  4836.       real_decl_result
  4837.     = FUNCTION_VALUE (TREE_TYPE (DECL_RESULT (current_function_decl)),
  4838.               current_function_decl);
  4839. #endif
  4840.       REG_FUNCTION_VALUE_P (real_decl_result) = 1;
  4841.       emit_move_insn (real_decl_result,
  4842.               DECL_RTL (DECL_RESULT (current_function_decl)));
  4843.       emit_insn (gen_rtx (USE, VOIDmode, real_decl_result));
  4844.     }
  4845.  
  4846.   /* If returning a structure, arrange to return the address of the value
  4847.      in a place where debuggers expect to find it.  */
  4848.   /* If returning a structure PCC style,
  4849.      the caller also depends on this value.
  4850.      And current_function_returns_pcc_struct is not necessarily set.  */
  4851.   if (current_function_returns_struct
  4852.       || current_function_returns_pcc_struct)
  4853.     {
  4854.       rtx value_address = XEXP (DECL_RTL (DECL_RESULT (current_function_decl)), 0);
  4855.       tree type = TREE_TYPE (DECL_RESULT (current_function_decl));
  4856. #ifdef FUNCTION_OUTGOING_VALUE
  4857.       rtx outgoing
  4858.     = FUNCTION_OUTGOING_VALUE (build_pointer_type (type),
  4859.                    current_function_decl);
  4860. #else
  4861.       rtx outgoing
  4862.     = hard_function_value (build_pointer_type (type),
  4863.                    current_function_decl);
  4864. #endif
  4865.  
  4866. #if 1
  4867.       /* If this works, leave it in.  */
  4868.       /* This is not really the function value,
  4869.      and it confuses integrate.c around line 1211.  */
  4870.       REG_FUNCTION_VALUE_P (outgoing) = 1;
  4871. #endif
  4872.  
  4873.       emit_move_insn (outgoing, value_address);
  4874.       use_variable (outgoing);
  4875.     }
  4876.  
  4877.   /* Output a return insn if we are using one.
  4878.      Otherwise, let the rtl chain end here, to drop through
  4879.      into the epilogue.  */
  4880.  
  4881. #ifdef HAVE_return
  4882.   if (HAVE_return)
  4883.     emit_jump_insn (gen_return ());
  4884. #endif
  4885.  
  4886.   /* Fix up any gotos that jumped out to the outermost
  4887.      binding level of the function.
  4888.      Must follow emitting RETURN_LABEL.  */
  4889.  
  4890.   /* If you have any cleanups to do at this point,
  4891.      and they need to create temporary variables,
  4892.      then you will lose.  */
  4893.   fixup_gotos (0, 0, 0, get_insns (), 0);
  4894. }
  4895.  
  4896. init_stmt ()
  4897. {
  4898.   obstack_init (&stmt_obstack);
  4899.   empty_cleanup_list = build_tree_list (NULL_TREE, NULL_TREE);
  4900. }
  4901.